Finding c and n0 by hand every time is slow. A few general theorems let you read off the growth class of most running times directly. This page proves the polynomial theorems correctly and adds the everyday rules for sums, products and chains of bounds.
The polynomial theorems
Let
f(n)=amnm+am−1nm−1+⋯+a1n+a0
be a polynomial of degree m, i.e. with leading coefficient am=0.
Proof. For n≥1 and k≤m we have nk≤nm, so
∣f(n)∣≤∑k=0m∣ak∣nk≤∑k=0m∣ak∣nm=cnm.■
Proof. For n≥1, the lower-order part satisfies am−1nm−1+⋯+a0≤Bnm−1. So
f(n)≥amnm−Bnm−1=nm−1(amn−B).
When n≥am2B, we have amn−B≥2amn, so f(n)≥2amnm. ■
Python · poly_lower.py
import math# f(n) = n^2 - 10n + 3: leading coefficient a_m = 1 > 0, m = 2.f = lambda n: n * n - 10 * n + 3print("f(1) =", f(1), " f(5) =", f(5), " f(20) =", f(20))a_m, B = 1, 10 + 3 # B = sum of |lower coefficients|n0 = max(1, math.ceil(2 * B / a_m))ok = all(f(n) >= (a_m / 2) * n * n for n in range(n0, 100001))print(f"n0 = {n0}: f(n) >= n^2/2 for all n from {n0} to 100000: {ok}")first = next(n for n in range(1, 1000) if all(f(k) >= k * k / 2 for k in range(n, 2000)))print("smallest n0 that works with c = 1/2:", first)
Output
f(1) = -6 f(5) = -22 f(20) = 203n0 = 26: f(n) >= n^2/2 for all n from 26 to 100000: Truesmallest n0 that works with c = 1/2: 20
The theorem’s n0=26 is safe but not the smallest; any valid n0 is enough for a proof.
Rules for combining bounds
These rules follow directly from the definitions and are used constantly in loop analysis (Unit 3).
Rule
Statement
Use
Constant factor
k⋅f(n)=Θ(f(n)) for any constant k>0
Drop constants.
Sum
f(n)+g(n)=Θ(max{f(n),g(n)})
Two loops one after the other: the bigger one wins.
Product
If f1=O(g1) and f2=O(g2) then f1f2=O(g1g2)
Nested loops multiply.
Transitivity
If f=O(g) and g=O(h) then f=O(h) (same for Ω, Θ)
Chain bounds.
Reflexivity
f=Θ(f)
—
Symmetry
f=Θ(g) if and only if g=Θ(f)
Θ behaves like equality.
Transpose symmetry
f=O(g) if and only if g=Ω(f)
O and Ω are opposite directions.
Logs vs powers
logan=O(nb) for all constants a>0, b>0
Any power beats any log.
Powers vs exponentials
na=O(bn) for all constants a>0, b>1
Any exponential beats any power.
Key takeaways
Any polynomial of degree m is O(nm) (use c=∑∣ak∣, n0=1, when f≥0).
With am>0 it is also Ω(nm), hence Θ(nm), from a suitable n0.
Sum rule: the larger term dominates; product rule: nested loops multiply.
Logs grow slower than any power, and powers slower than any exponential.
Practice questions
Answer on paper first, then check. The explanation matters more than the letter you chose.
Question 6 · short answer
Using the theorems, give O, Ω and Θ for f(n)=6n4+2n2+9 and give explicit constants for Θ.
Show worked answer
Degree 4, leading coefficient 6 > 0, so f(n) = O(n⁴), Ω(n⁴) and Θ(n⁴). Constants: all terms are positive, so 6n⁴ ≤ 6n⁴ + 2n² + 9 for n ≥ 1; and 2n² ≤ 2n⁴, 9 ≤ 9n⁴ for n ≥ 1, so f(n) ≤ 17n⁴. Hence 6n⁴ ≤ f(n) ≤ 17n⁴ for all n ≥ 1: c₁ = 6, c₂ = 17, n₀ = 1.
MCA Online notes are made for reading on screen. Open https://mcastudy.online/mcs-211/some-pre-requisites-and-asymptotic-bounds/useful-theorems-for-o-and/ to read this page.