Overview

This chapter tackles the selection problem: given a set of n distinct numbers, find the i-th smallest element (the i-th order statistic). While sorting solves this in O(n lg n) time, the chapter demonstrates that selection can be performed in Θ(n) time — both in expectation (via a randomized algorithm) and in the worst case (via the deterministic median-of-medians strategy). These results are significant because they show that selection is fundamentally easier than sorting, bypassing the Ω(n lg n) comparison-sort lower bound without making any assumptions about the input.

Key Concepts

Algorithms and Techniques

9.1 — MINIMUM (and MAXIMUM)

Idea: Scan the array once, tracking the smallest element seen so far.

MINIMUM(A):
  min = A[1]
  for i = 2 to A.length:
      if A[i] < min:
          min = A[i]
  return min

Simultaneous min and max (pairwise technique):

Rather than finding min and max independently (2n − 2 comparisons), process elements in pairs:

  1. Compare the two elements of each pair with each other (1 comparison).

  2. Compare the smaller of the pair against the running minimum (1 comparison).

  3. Compare the larger of the pair against the running maximum (1 comparison).