edited by
608 views
0 votes
0 votes

Consider the following code segment:

int j, k,n;

for(j=1;j<=n-1;j++){

   for(k=j+1;k<n;k++){

      if(A[j]> A[k]){

        A[j]=A[j+2];

      }

   }

}

(Where is the size of array A[ ] and starting index is 1)
Number of comparison made by the above code when = 84 ________.

 

given answer is 84*83/2 =3486

shouldn’t it be 83*82/2 = 3403 

edited by

Please log in or register to answer this question.

Related questions

0 votes
0 votes
2 answers
1
Akriti sood asked Dec 28, 2016
822 views
The number of comparisons required to search 48 in hash table with chaining is pos = x % 10. The elements inserted into hashtable is0, 32, 42, 200, 150, 22, 48, 120, 18, ...
0 votes
0 votes
1 answer
2