Question PSC-ARR-0073
HardWhat will be printed by the following pseudocode?
Integer a[5] = {2, 4, 1, 3, 5}
Integer i, j, inv = 0
for (each i from 0 to 4)
for (each j from i + 1 to 4)
if (a[i] > a[j]) inv = inv + 1 end if
end for
end for
Print inv
- A.
3
- B.
2
- C.
Sign up free to see the answer and a step-by-step explanation.