Consider the following code segment:
int j, k,n;
(Where n is the size of array A[ ] and starting index is 1)
Number of comparison made by the above code when n = 84 ________.
given answer is 84*83/2 =3486
shouldn’t it be 83*82/2 = 3403
are u speaking about the comparisons of the inner for loop or the comparison that is being performed inside the loop, i.e. (A[j]> A[k]) ??
I guess that we shouldnt consider only the comparisons performed by A[j]> A[k] .
What about the comparisons made in the inner and outer for loops?shouldnt we consider them too?
pls verify Shaik Masthan