GATE Computer ScienceVery hardGATE CSE

Randomised quicksort picks the pivot uniformly at random from the current sub-array and each partition of m elements uses exactly m−1 comparisons. For 6 distinct keys, the expected total number of comparisons is

  1. A. 9.5
  2. B. 11.2
  3. C. 10.3
  4. D. 12.0

Correct answer: C. 10.3

Using E(n) = 2(n+1)H_n − 4n with H_6 = 2.45 gives 10.3 (checked by averaging first-pivot quicksort over all 720 permutations).

More Algorithms questions

Exams that ask this topic