MCS-211 · Block 1 Unit 2

Some Pre-requisites and Asymptotic Bounds

Section 8 of 8

Block 1 · Unit 2Some Pre-requisites and Asymptotic Bounds11 min · Section 8 of 8

2.8Useful Theorems for O, Ω and Θ

Covers IGNOU MCS-211 §2.7.4

Finding cc and n0n_0 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+a0f(n) = a_m n^m + a_{m-1} n^{m-1} + \dots + a_1 n + a_0 be a polynomial of degree mm, i.e. with leading coefficient am≠0a_m \ne 0.

Proof. For n≥1n \ge 1 and k≤mk \le m we have nk≤nmn^k \le n^m, so ∣f(n)∣≤∑k=0m∣ak∣nk≤∑k=0m∣ak∣nm=c nm.■|f(n)| \le \sum_{k=0}^{m} |a_k| n^k \le \sum_{k=0}^{m} |a_k| n^m = c\, n^m. \qquad \blacksquare

Proof. For n≥1n \ge 1, the lower-order part satisfies ∣am−1nm−1+⋯+a0∣≤B nm−1\left|a_{m-1} n^{m-1} + \dots + a_0\right| \le B\, n^{m-1}. So f(n)≥amnm−Bnm−1=nm−1(amn−B).f(n) \ge a_m n^m - B n^{m-1} = n^{m-1}(a_m n - B). When n≥2Bamn \ge \frac{2B}{a_m}, we have amn−B≥amn2a_m n - B \ge \frac{a_m n}{2}, so f(n)≥am2nmf(n) \ge \frac{a_m}{2} n^m. ■\blacksquare

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 + 3
print("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) = 203
n0 = 26: f(n) >= n^2/2 for all n from 26 to 100000: True
smallest n0 that works with c = 1/2: 20

The theorem’s n0=26n_0 = 26 is safe but not the smallest; any valid n0n_0 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).

RuleStatementUse
Constant factork⋅f(n)=Θ(f(n))k \cdot f(n) = \Theta(f(n)) for any constant k>0k > 0Drop constants.
Sumf(n)+g(n)=Θ(max⁡{f(n),g(n)})f(n) + g(n) = \Theta(\max\{f(n), g(n)\})Two loops one after the other: the bigger one wins.
ProductIf f1=O(g1)f_1 = O(g_1) and f2=O(g2)f_2 = O(g_2) then f1f2=O(g1g2)f_1 f_2 = O(g_1 g_2)Nested loops multiply.
TransitivityIf f=O(g)f = O(g) and g=O(h)g = O(h) then f=O(h)f = O(h) (same for Ω, Θ)Chain bounds.
Reflexivityf=Θ(f)f = \Theta(f)—
Symmetryf=Θ(g)f = \Theta(g) if and only if g=Θ(f)g = \Theta(f)Θ behaves like equality.
Transpose symmetryf=O(g)f = O(g) if and only if g=Ω(f)g = \Omega(f)O and Ω are opposite directions.
Logs vs powerslog⁡an=O(nb)\log^a n = O(n^b) for all constants a>0a > 0, b>0b > 0Any power beats any log.
Powers vs exponentialsna=O(bn)n^a = O(b^n) for all constants a>0a > 0, b>1b > 1Any exponential beats any power.

Key takeaways

  • Any polynomial of degree mm is O(nm)O(n^m) (use c=∑∣ak∣c = \sum |a_k|, n0=1n_0 = 1, when f≥0f \ge 0).
  • With am>0a_m > 0 it is also Ω(nm)\Omega(n^m), hence Θ(nm)\Theta(n^m), from a suitable n0n_0.
  • 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 1 · multiple choice

What is the tight bound of f(n)=4n5−100n4+7f(n) = 4n^5 - 100n^4 + 7?

Show answer

Answer: B. Θ(n5)\Theta(n^5)

Degree 5 with positive leading coefficient 4, so Θ(n⁵). The large negative coefficient −100 only delays n₀; it does not change the class.

Question 2 · multiple choice

Which constant cc does the upper-bound theorem give for f(n)=2n3−3n+5f(n) = 2n^3 - 3n + 5?

Show answer

Answer: C. 10

c = |2| + |−3| + |5| = 10, so f(n) ≤ 10n³ for n ≥ 1. 4 = 2 − 3 + 5 forgets the absolute values.

Question 3 · multiple choice

Two loops run one after the other: the first takes Θ(n2)\Theta(n^2) time and the second Θ(nlog⁡n)\Theta(n \log n). The total is:

Show answer

Answer: A. Θ(n2)\Theta(n^2)

Sequential parts add, and the sum is Θ of the larger term, n². Multiplying is for nested loops.

Question 4 · multiple choice

Which statement is true for all large nn?

Show answer

Answer: D. log⁡3n=O(n0.1)\log^3 n = O(n^{0.1})

Any power of log n grows more slowly than any positive power of n. Exponentials beat powers, so the other three are false.

Question 5 · multiple choice

Why is f(n)=−n2+5nf(n) = -n^2 + 5n not Ω(n2)\Omega(n^2)?

Show answer

Answer: C. Because its leading coefficient is negative, so f(n)f(n) becomes negative for large nn.

For n > 5, f(n) < 0, so f(n) ≥ c·n² with c > 0 is impossible. The degree is 2; the sign is what fails.

Question 6 · short answer

Using the theorems, give O, Ω and Θ for f(n)=6n4+2n2+9f(n) = 6n^4 + 2n^2 + 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.

↑ ↓ move↵ openTab switch type