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.
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.










