- The ith order statistic of a set A of n elements is the ith smallest element.
- The minimum of a set is the first order statistic (i=1)
- The maximum of a set is the nth order statistic (i=n)
- The median is i=⌊(n+1)/2⌋
- The rank r of an element is its position in the linear order of the set
Problem
- Intput: A set A of n (distinct) numbers and an integer i, with 1≤i≤n.
- Output: The element x∈A that is larger then exactly i−1 other elements of A.
Algortihems
- The General case:
- Randomized-Select takes Θ(n) in average case
- Select takes Θ(n) time in the worst case
- Using in Order-statistic tree (RB Tree with additional node field: size). OS-Select takes O(lgn) time in the worst case.
- Speical cases:
- (9.1) finding min and max simultaneously in 3⌊n/2⌋=O(n) comparisons
- (e9.1.1) finding the second smallest in n+⌈lgn⌉−2 comparisons