Data Structures & AlgorithmsVery hardGATE CS · competitive programming

Finding the k-th smallest element with a median-of-medians pivot is used as a deterministic selection method. What is its worst-case time complexity?

  1. A. O(n log k)
  2. B. O(n log n)
  3. C. O(n)
  4. D. O(n²)

Correct answer: C. O(n)

The median-of-medians pivot guarantees a split of at least 30% on each side, so T(n) ≤ T(n/5) + T(7n/10) + O(n), which solves to O(n). A fixed-pivot quickselect can degrade to O(n²).

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic