Quickselect Algorithm

See choice algorithm for further discussion of the connection with sorting. like quicksort, it was developed by Tony Hoare, and thus is also known as Hoare's choice algorithm.

Quickselect source code, pseudocode and analysis

It is also an in-place algorithm, necessitate only constant memory overhead if tail call optimization is available, or if eliminate the tail recursion with a loop: function select(list, left, correct, K) is loop This simple procedure has expected linear performance, and, like quicksort, has quite good performance in practice.