• + 2 comments

    Agreed! The average-case solution for QuickSelect is indeed O(n). Unfortunately, when the list is sorted (or "nearly" sorted), your algorithm will degenerate to the worst-case of O(n*n)... :(