Overview
Quickselect partitions an array around a pivot and keeps only the side that contains the desired rank. It is related to quicksort but recurses into one partition instead of both.
Finds the kth smallest item by partitioning around pivots without fully sorting.
Compact metadata for implementation and discovery.
Quickselect partitions an array around a pivot and keeps only the side that contains the desired rank. It is related to quicksort but recurses into one partition instead of both.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n)
Worst
O(n^2)
Space
O(1)
Show partitions being discarded until the desired rank remains.
Quickselect is usually destructive because partitioning rearranges the array.
What each reference supports for this entry.
Original selection algorithm reference for partition-based order statistic search.
Open sourceAlgorithms textbook support for Quickselect's invariant, correctness argument, and asymptotic analysis.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Both use partitioning around pivots, but quickselect follows only one side.
Floyd-Rivest adds sampling to reduce expected comparisons.