← Back to All Algorithms

šŸŽÆ Quickselect

Find k-th Smallest Element

Uses Quicksort-style partitioning but only recurses on ONE side:

  1. Partition array around pivot
  2. If pivot position = k, done!
  3. If k < pivot position, search left
  4. If k > pivot position, search right

Expected: O(n) | Worst: O(n²)

Find 3rd smallest element (k = 3)
Low: 0 High: 7 Pivot Position: -
Click "Start" to find the k-th smallest