Question DSA-SORT-0043
MediumWhat is the output of this code?
a = [4, 3, 2, 10, 12, 1, 5, 6]
for i in range(1, len(a)):
key, j = a[i], i - 1
while j >= 0 and a[j] > key:
a[j + 1] = a[j]
j -= 1
a[j + 1] = key
if i == 3:
print(a)
- A.
[2, 3, 4, 10, 12, 1, 5, 6]
- B.
[3, 4, 2, 10, 12, 1, 5, 6]
- C.
Sign up free to see the answer and a step-by-step explanation.