Median Of Running Array Algorithm

Introselect begins with quickselect (with random pivot, default), to obtain good average performance, and then falls back to modify quickselect with pivot obtained from median of medians if the progress is too slow. Although this approach optimizes the asymptotic worst-case complexity quite well, it is typically outperformed in practice by instead choose random pivots for its average O(n) complexity for choice and average O(n

Median Of Running Array source code, pseudocode and analysis

N is in the group of larger elementsMove all components smaller than the pivot to the left of the pivot for i from leave to right − 1