01 / 20

Asymptotic Notation
\( O \), \( \Theta \), \( \Omega \)

Learn the language of algorithm efficiency: how to classify growth rates using Big-O, Big-Theta, and Big-Omega notation.

Discrete Math

Why Growth Rates Matter

When we analyze algorithms, we care about how the running time or space usage scales as the input size \( n \) grows large. A function that runs in \( n^2 \) steps is fine for \( n = 10 \), but devastating for \( n = 10^6 \).

\( O \) Upper Bound
"At most this fast"
\( \Theta \) Tight Bound
"Exactly this fast"
\( \Omega \) Lower Bound
"At least this fast"

What Is Big-O Notation?

\( O(g(n)) \) describes an upper bound on the growth of a function. We say \( f(n) \in O(g(n)) \) if, beyond some point, \( f(n) \) never exceeds a constant multiple of \( g(n) \).

Think of it as a ceiling on growth. If \( f(n) \in O(n^2) \), the function grows no faster than \( n^2 \) (up to a constant factor) for sufficiently large \( n \).

Visualizing \( O(g(n)) \)

n time
\( c \cdot g(n) \)
\( f(n) \)
\( n_0 \)
for all \( n \geq n_0 \): \( f(n) \leq c \cdot g(n) \)

What Is Big-Omega Notation?

\( \Omega(g(n)) \) describes a lower bound on growth. We say \( f(n) \in \Omega(g(n)) \) if \( f(n) \) grows at least as fast as \( g(n) \) for large \( n \).

Think of it as a floor on growth. If \( f(n) \in \Omega(n) \), it takes at least linear time, no matter how clever the implementation.

What Is Big-Theta Notation?

\( \Theta(g(n)) \) describes a tight bound: \( f(n) \) grows at exactly the same rate as \( g(n) \), sandwiched between two constant multiples.

The \( \Theta \) Sandwich

n time
\( c_2 \cdot g(n) \)
\( f(n) \)
\( c_1 \cdot g(n) \)
\( n_0 \)

Comparing \( O \), \( \Theta \), and \( \Omega \)

Notation Bound Type Analogy Condition
\( O(g(n)) \) Upper bound \( \leq \) \( f(n) \leq c \cdot g(n) \)
\( \Omega(g(n)) \) Lower bound \( \geq \) \( f(n) \geq c \cdot g(n) \)
\( \Theta(g(n)) \) Tight bound \( = \) Both \( O \) and \( \Omega \)

The Growth Rate Hierarchy

n time
\( O(1) \)
\( O(\log n) \)
\( O(n) \)
\( O(n \log n) \)
\( O(n^2) \)
\( O(2^n) \)

How to Prove Big-O

1
Identify \( f(n) \) and the proposed \( g(n) \).
2
Find constants \( c > 0 \) and \( n_0 \geq 0 \) such that \( f(n) \leq c \cdot g(n) \) for all \( n \geq n_0 \).
3
Simplify \( f(n) \) by bounding each term: replace lower-order terms and constants with the dominant term.
4
State your witnesses: write the specific \( c \) and \( n_0 \) values and verify the inequality holds.

Example: \( 3n + 5 \in O(n) \)

Claim: \( f(n) = 3n + 5 \) is in \( O(n) \).

1
We need \( 3n + 5 \leq c \cdot n \) for some \( c \) and all \( n \geq n_0 \).
2
For \( n \geq 1 \): \( 5 \leq 5n \), so \( 3n + 5 \leq 3n + 5n = 8n \).
3
Choose \( c = 8 \) and \( n_0 = 1 \).
4
Verify: \( 3(1) + 5 = 8 \leq 8(1) = 8 \). ✓ For all \( n \geq 1 \): \( 3n + 5 \leq 8n \). ✓

Example: \( 2n^2 + 3n \in \Theta(n^2) \)

Claim: \( f(n) = 2n^2 + 3n \) is in \( \Theta(n^2) \). We must prove both \( O(n^2) \) and \( \Omega(n^2) \).

\( O(n^2) \) upper bound
For \( n \geq 1 \): \( 3n \leq 3n^2 \), so \( 2n^2 + 3n \leq 5n^2 \). Choose \( c_2 = 5, n_0 = 1 \). ✓
\( \Omega(n^2) \) lower bound
For all \( n \geq 0 \): \( 2n^2 + 3n \geq 2n^2 \). Choose \( c_1 = 2, n_0 = 0 \). ✓

Example: \( n^2 \notin O(n) \)

Claim: \( n^2 \) is not in \( O(n) \). We prove this by contradiction.

1
Assume \( n^2 \in O(n) \). Then there exist \( c > 0 \) and \( n_0 \) such that \( n^2 \leq c \cdot n \) for all \( n \geq n_0 \).
2
Divide both sides by \( n \) (valid for \( n > 0 \)): \( n \leq c \).
3
But \( n \) can be arbitrarily large: pick \( n = c + 1 \). Then \( c + 1 \leq c \), a contradiction.

Useful Simplification Rules

1
Drop constants: \( O(5n) = O(n) \). Constant factors don't affect asymptotic class.
2
Drop lower-order terms: \( O(n^2 + n) = O(n^2) \). The dominant term wins.
3
Sum rule: \( O(f + g) = O(\max(f, g)) \). The larger function dominates.
4
Product rule: \( O(f \cdot g) = O(f) \cdot O(g) \). Multiply the bounds.
5
Polynomials: \( a_k n^k + \cdots + a_1 n + a_0 \in \Theta(n^k) \). The leading term determines the class.

Common Mistakes

✕ Confusing \( O \) with \( \Theta \)
Saying "\( f(n) \) is \( O(n^2) \)" when you mean it's exactly quadratic. \( 3n \in O(n^2) \) is true but imprecise.
✕ Keeping constants
Writing \( O(2n) \) or \( O(3n^2 + 1) \). Asymptotic notation absorbs constants: simplify to \( O(n) \) or \( O(n^2) \).
✕ Wrong direction
Proving \( f(n) \geq c \cdot g(n) \) when trying to show Big-O (which requires \( \leq \)). Mixing up \( O \) and \( \Omega \) inequalities.

Quick Reference Table

Function Big-O Big-\(Omega\) Big-\(Theta\)
\( 5n + 3 \) \( O(n) \) \( \Omega(n) \) \( \Theta(n) \)
\( 4n^2 + n \) \( O(n^2) \) \( \Omega(n^2) \) \( \Theta(n^2) \)
\( n^3 + 100n \) \( O(n^3) \) \( \Omega(n^3) \) \( \Theta(n^3) \)
\( \log n + 7 \) \( O(\log n) \) \( \Omega(\log n) \) \( \Theta(\log n) \)
\( 2^n + n^5 \) \( O(2^n) \) \( \Omega(2^n) \) \( \Theta(2^n) \)

Question 1 of 5

Which statement is the tightest correct bound for \( f(n) = 7n + 12 \)?

Question 2 of 5

If \( f(n) \in O(n^2) \) and \( f(n) \in \Omega(n^2) \), what can we conclude?

Question 3 of 5

To prove \( 5n^2 + 3n + 1 \in O(n^2) \), we choose \( c \) and \( n_0 \). Which pair works?

Question 4 of 5

Which of the following is false?

Question 5 of 5

What is the tight bound for \( f(n) = 3n \log n + 2n + 100 \)?