Computer Science EngineeringHardISRO SC (CS)

Quicksort picks the first element as pivot and partitions into smaller/larger lists (each remaining element is compared once with the pivot per call). Sorting [31, 32, 4, 12, 37, 25, 24] makes how many element-to-pivot comparisons in total?

  1. A. 14
  2. B. 13
  3. C. 12
  4. D. 21

Correct answer: B. 13

Add (size-1) over every recursive call: 13.

More Algorithms, Data Structures & Programming (ISRO CS) questions

Exams that ask this topic