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