GATE / CS ARCHIVE

GATE CSE 2008 / QUESTION 43

Quicksort recurrence from bounded partition sizes

Algorithms · Searching, Sorting & Selection · Full GATE CSE 2008 paper

GATE 2008, Q43 2 marks · MCQ
Report issue

Searching, Sorting & Selection

Question 43, GATE 2008: A quicksort pivot procedure splits the list into two sublists each containing at least n/5 elements. If T(n) counts sorting comparisons, which offered upper recurrence follows?

(A) T(n)≤2T(n/5)+n
(B) T(n)≤T(n/5)+T(4n/5)+n
(C) T(n)≤2T(4n/5)+n
(D) T(n)≤2T(n/2)+n
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Each recursive subproblem has size at most 4n/5, because each side has at least n/5 elements. With the usual monotone worst-case upper-bound interpretation of T and linear partitioning cost, both recursive costs are bounded individually by T(4n/5), so T(n)≤2T(4n/5)+n, option C.
2. This loose recurrence follows immediately from the given size bounds. The tempting expression T(n/5)+T(4n/5)+n assumes that the most unequal permitted split maximizes the sum of recursive costs; monotonicity alone does not establish that.
3. More precisely the general recurrence is T(n)≤maxn/5≤k≤4n/5{T(k)+T(n−k)}+O(n), ignoring pivot/rounding constants. The standard comparison model includes linear partition/pivot overhead; the statement does not specify the cost of an arbitrary extra pivot-selection procedure.

Original paper, page 7