Quickselect Algorithm - Find elements by rank without sorting! @NERDfirst
Quickselect Algorithm - Find elements by rank without sorting!  @NERDfirst
Uploaded November 2025 | Updated November 2026, 3 hours ago
How do you quickly find the kth smallest element in a list? While sorting the whole list might be one way of doing it, Quickselect is a quicker method, with an average O(n) time complexity! Turns out, by making a slight tweak to our understanding of Quicksort, we can easily solve a selection problem as well!

0:00 Introduction
1:20 Recap: Lomuto's Partitioning Algorithm
3:30 Driving Partitioning for Quicksort / Quickselect
5:19 Full Trace of Quickselect
8:13 Pseudocode: Partition Function
9:52 Pseudocode: Quickselect Function
11:31 Python Code + Run
13:28 Time Complexity Intuition
17:37 Time Complexity Generalization (Formal)
20:38 Caveats of Quickselect

-----

Want to contribute to the channel? Consider using the "Super Thanks" feature above, or visit my website at nerdfirst.net/donate to find alternative ways to donate. Thank you!

-----

Disclaimer: Please note that any information is provided on this channel in good faith, but I cannot guarantee 100% accuracy / correctness on all content. Contributors to this channel are not to be held responsible for any possible outcomes from your use of the information.
Quickselect Algorithm - Find elements by rank without sorting!Straight vs Crossed Cables - Friday Minis 255Vlog: I surveyed Reddit and got 896 responses!Locales & Pseudolocales - Friday Minis 254Some Travel Adapters are Dangerous!Cache & Locality - Friday Minis 268Firefoxs Screenshot Node - Friday Minis 231Quick Update Vlog!Floating Point Numbers - A Contents PageGenerative Adversarial Networks - Friday Minis 303Sources vs Sinks - Friday Minis 253Floor and Ceiling - Friday Minis 306
0612 TV w/ NERDfirst |

Quickselect Algorithm - Find elements by rank without sorting!

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER