4,852 views
2 votes
2 votes

In the code fragment below, first and last are integer values and composite(x) is a function that returns true if x is not a prime number and false otherwise.

i := 0; j := 0; k := 0;
for (m := last; m >= first; m := m-1){
  k := k + m;
  if (composite(m)){
    i := i + m;
  }else{
    j := j + m;
  }
}
 

At the end of the loop: 

  1. k < i+j
  2. k = i+j
  3. k > i+j
  4. The relationship between i, j and k depends on the values of first and last

im getting option 2 , is it correct ?

Please log in or register to answer this question.

Related questions

0 votes
0 votes
0 answers
1
Dulqar asked Jan 24, 2017
4,965 views
if T(n) = n2 √ n thenT(n) = O(n2)T(n) = O(n2 log n)T(n) = O(n3)None of the aboveIm getting option 2 is it correct ?
0 votes
0 votes
1 answer
3