Chapter 9Complexity Analysisslides.en.pdf:205

Growth Ranking

O(1) ⊂ O(log n) ⊂ O(n) ⊂ O(n²) ⊂ O(nᵏ) ⊂ O(kⁿ)

Theorem 0.5Growth ranking
Concept

Growth Ranking Lemma (Lemma 0.5):

O(1)O(logn)O(n)O(nlogn)O(n2)O(nk)O(2n)O(1) \subset O(\log n) \subset O(n) \subset O(n \log n) \subset O(n^2) \subset O(n^k) \subset O(2^n)

These classes are nested: every constant function is eventually bounded by
every logarithmic function; every logarithmic by every linear; etc.

Why this matters. When you analyze an algorithm, identifying its growth
class lets you compare it to others without doing exact arithmetic. "Is it
better than O(n2)O(n^2)?" is a meaningful question; "is it 7n27n^2 or
8n28n^2?" usually is not.

Reading the chain:
- O(1)O(1): hash table lookup. Independent of nn.
- O(logn)O(\log n): binary search. Each step halves the problem.
- O(n)O(n): scan a list once.
- O(nlogn)O(n \log n): merge sort, heap sort. Best general-purpose sorting.
- O(n2)O(n^2): bubble sort, naive all-pairs.
- O(nk)O(n^k): polynomial. Acceptable for small kk.
- O(2n)O(2^n): subset enumeration. Becomes infeasible fast.

Crucial observation. Polynomial vs. exponential is the cliff. Anything
polynomial is "tractable" for reasonable nn (within hardware limits).
Anything exponential hits a wall around n50n \approx 50.

Proving O(logn)O(n)O(\log n) \subset O(n): any fO(logn)f \in O(\log n) is bounded by
clognc \log n. We need cnc' n for large nn. Take n2n \geq 2: lognn\log n \leq n.
So clogncncnc \log n \leq cn \leq c' n with c=cc' = c. ✓

Each step in the chain has a similar proof using elementary inequalities.

Animation — big o growth
Transcript — click a line to jump8 cues
  1. 0.0sGrowth of Common Functions
  2. 0.8sAxes drawn: n on the horizontal, f(n) on the vertical.
  3. 1.8sConstant 1: flat baseline.
  4. 2.6slog n: barely rises across the entire range.
  5. 3.4sn: a steady diagonal line.
  6. 4.2sn squared: curves up gently at first, steepens later.
  7. 5.0s2 to the n: explodes exponentially and dwarfs every other curve.
  8. 6.4sExponential eventually overtakes everything.
Practice — score 100% to advance
Multiple choice
Q1
Which is correct: O(n)O(nlogn)O(n) \subset O(n \log n)?
Q2
Which is the fastest growth class in this list?
Q3
Why is the polynomial-vs-exponential boundary important?
Q4
Binary search is in which class?
Q5
Is O(n2)O(n3)O(n^2) \subset O(n^3)?
Q6
Is O(2n)O(nk)O(2^n) \subset O(n^k) for any kk?
Order the steps
Arrange these proof steps in the correct order using the arrows.
1
O(nk)O(n^k) — polynomial. Tractable for small kk; large kk is borderline.
2
O(logn)O(\log n) — logarithmic. Binary search. Doubling nn adds one step.
3
O(2n)O(2^n) — exponential. Subsets, brute force. Infeasible past n50n \approx 50.
4
O(n2)O(n^2) — quadratic. All-pairs. Doubling nn quadruples the work.
5
O(nlogn)O(n \log n) — log-linear. Merge sort. The classic sorting bound.
6
O(1)O(1) — constant. Hash table lookup. Independent of nn.
7
O(n)O(n) — linear. Single scan. Doubling nn doubles the work.
Loading…