GATE / CS ARCHIVE

GATE CSE 2001 / QUESTION 1.14

Worst case of randomized quicksort

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

GATE 2001, Q1.14 1 mark · MCQ
Report issue

Searching, Sorting & Selection

Question 1.14, GATE 2001: Quicksort selects each pivot randomly. What is its worst-case sorting complexity on n values: O(n), O(n log n), O(n²), or O(n!)?
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

Step 1: Random pivot selection improves the expected split quality, but it does not make extreme pivots impossible. A sequence selecting the minimum or maximum at every partition still has nonzero probability.

Step 2: That sequence performs(n−1)+(n−2)+…+1=n(n−1)/2 partition comparisons, yielding Θ(n²).

Thus C is the tight worst-case bound. Θ(n log n) is the expected runtime over the random choices, not the maximum possible runtime of a particular execution.

Original paper, page 2