Memra

Asymptotic notation: Θ, O, Ω (and o, ω)

◈ 4 cards

The formal (c, n₀) definitions, Θ ⇔ O ∧ Ω, proving a bound from the definition, the growth hierarchy, and the traps the exam loves.

Why we compare growth rates

We judge algorithms by how their cost grows as , dropping constant factors and lower-order terms. For large those details are dominated by the leading term, so the order of growth is what actually distinguishes algorithms — and it is machine-independent.

The three bounds, formally

Each notation is a set of functions, defined by exhibiting constants. To prove membership you only need to find one valid pair (or triple) of constants.

  • — asymptotic upper bound ("no faster than"). iff there exist constants with for all .
  • — asymptotic lower bound ("at least as fast as"). iff there exist with for all .
  • — asymptotically tight bound ("exactly this rate"). iff there exist with for all .

The single most useful fact (Theorem 3.1) glues them together:

So to prove a tight bound, prove the upper bound and the lower bound separately and cite the theorem — far easier than juggling and at once.

Worked example — prove from the definition

Upper (). Want . Divide by : . At the left side is at most , so works. Hence .

Lower (). Want . Since , , so and any works. Hence .

Both bounds hold, so by Theorem 3.1, — with , , .

The general technique: to disprove an bound (e.g. ), assume it holds, divide by the target, and show the required would have to grow with — impossible for a fixed constant.

Strict bounds: o and ω

Little-oh and little-omega are the strict versions, where the bound holds for every :

  • means grows strictly slower than , i.e. (e.g. ).
  • means grows strictly faster, i.e. .

The number-line analogy: , , , , . But beware: trichotomy fails — two functions can be incomparable (neither nor of each other), unlike real numbers.

The growth hierarchy you must know cold

The two master rules behind it: any polylog is beaten by any positive polynomial (), and any polynomial is beaten by any exponential ( for $a > 1$). And — the seed of the comparison-sort lower bound.

notationboundcondition for n ≥n₀mirrorsO(g)upper0 ≤ f ≤ c·gΩ(g)lower0 ≤ c·g ≤ fΘ(g)tight0 ≤ c₁g ≤ f ≤ c₂g=o(g)strict upperf/g → 0<ω(g)strict lowerf/g → ∞>O and Ω need one constant c; o and ω must hold for every c > 0. "At least O(n²)" is meaningless — Oalready says "at most". And trichotomy fails: two functions can be incomparable.
The five notations. Membership is proved by exhibiting constants — and a Θ bound is cheapest to prove as an O proof plus an Ω proof (Theorem 3.1).
O(n!)factorialO(2ⁿ)exponentialO(n³)O(n²)polynomialO(n lg n)O(n)linear — O(lg n) and O(1) nest insidegrows fastestgrows slowest
Each O class is a set of functions and the sets nest: anything in O(n) is also in O(n lg n). The hierarchy is containment, not merely ordering.
NORMAL ~/memra/learn/comp-372/asymptotic-notation utf-8 LF