ā Back to All Algorithms
šÆ Quickselect
Find k-th Smallest Element
Uses Quicksort-style partitioning but only recurses on ONE side:
Partition array around pivot
If pivot position = k, done!
If k < pivot position, search left
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
Reset
ā¶ Start
Step ā