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