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.
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 \).
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)) \)
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
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
How to Prove Big-O
Example: \( 3n + 5 \in O(n) \)
Claim: \( f(n) = 3n + 5 \) is in \( O(n) \).
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) \).
Example: \( n^2 \notin O(n) \)
Claim: \( n^2 \) is not in \( O(n) \). We prove this by contradiction.
Useful Simplification Rules
Common Mistakes
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 \)?