Question DSA-SORT-0044
MediumWhat is the output of this code?
def part(a, lo, hi):
p, i = a[hi], lo
for j in range(lo, hi):
if a[j] < p:
a[i], a[j] = a[j], a[i]
i += 1
a[i], a[hi] = a[hi], a[i]
return i
a = [7, 2, 9, 4, 3, 8, 5]
k = part(a, 0, len(a) - 1)
print(k, a)
- A.
3 [4, 2, 3, 5, 9, 8, 7]
- B.
4 [2, 4, 3, 7, 5, 8, 9]
- C.
Sign up free to see the answer and a step-by-step explanation.