Selection
Let S be a totally ordered set of n pairwise distinct elements. The rank of an element s in S is k if and only if S contains exactly k-1 elements that are smaller than s.
Given: a set S with n elements and a number k
Want: the element s in S of rank k
We assume that there is a funkction splitter(S) that finds an element in S whose ranke lies between n/4 and 3n/4. If splitter(S) does not cause any additional running time, we can solve the selection problem in O(n) time.
The pseudocode can be found in the notes in the attachment.
This method is called prune and search: in each iteration, a constant fraction of the input (e.g., at least a quarter) is pruned and the seach is continued in the remainder.