Data Structures & AlgorithmsModerateProduct Company SDE · selection

Problem: Which algorithm finds the k-th smallest element in expected linear time?

  1. A. Heapsort
  2. B. Quickselect (randomised partitioning)
  3. C. Merge sort
  4. D. Insertion sort

Correct answer: B. Quickselect (randomised partitioning)

Quickselect recurses into one side of a random pivot, with expected total work O(n).

More Coding Interview Problems questions

Exams that ask this topic