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 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
Sir, I will say the "THE PURPOSE OF...