Quicksort is run on the two inputs below to sort them in ascending order,…
GATE · 1996 · CS · Question 2 subpartsModified — slightly modified from the official paper; see the solution
Quicksort is run on the two inputs below to sort them in ascending order, using the first element as the pivot:
(i) 1, 2, 3, ..., n
(ii) n, n−1, n−2, ..., 2, 1Let C1 and C2 be the numbers of element-to-pivot comparisons made for inputs (i) and (ii), respectively. Then:
- A.
C1 < C2
- B.
C1 > C2
- C.
C1 = C2
- D.
We cannot say anything for arbitrary n
Attempted by 191 students.
Sign up free to check your answer
Sign up freeLoading lesson…