GATE / CS ARCHIVE

GATE CSE 2009 / QUESTION 39

Quicksort with a fixed-rank fractional pivot

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

GATE 2009, Q39 2 marks · MCQ
Report issue

Searching, Sorting & Selection

Question 39, GATE 2009: Quicksort selects the n/4-th smallest key as pivot using a linear-time selection algorithm. What is its worst-case time? A Θ(n); B Θ(n log n); C Θ(n²); D Θ(n² log n).
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Selecting the one-quarter order statistic in linear time gives recurrence T(n)=T(n/4)+T(3n/4−1)+Θ(n). Each recursion level has linear total work, and the longest/shortest nontrivial paths are logarithmic up to constants. Equivalently the Akra–Bazzi exponent is 1 because 1/4+3/4=1. Thus Θ(n log n), B, assuming rank partitioning is implemented appropriately for distinct keys or duplicates.

At each partition, linear-time selection plus partitioning costs Θ(n), and subproblems have sizes approximately n/4 and 3n/4. Both are fixed fractions, so recursion depth is Θ(log n); total size across a complete level remains proportional to n until leaves. Consequently total cost is Θ(n log n). Choosing the quarter-rank pivot is not perfectly balanced, but still prevents the n−1 versus 0 split responsible for quadratic quicksort.

Original paper, page 9