Sub topic 7
Big Omega and Big Theta: Lower and Tight Bounds
This chapter assumes you know the formal definition of Big O and how to drop constants and lower-order terms. Big O only says a function grows no faster than some bound. Two companion notations cover the other directions.
Big Omega: a lower bound
Big Omega, written Ω, says a function grows at least as fast as a bound. Formally, f(n) = Ω(g(n)) if there are constants c > 0 and n0 such that f(n) ≥ c · g(n) for all n ≥ n0.
It is the mirror image of Big O. The two definitions differ only in the direction of the inequality.
Big Theta: a tight bound
Big Theta, written Θ, says a function is bounded above and below by the same growth rate. Formally, f(n) = Θ(g(n)) if there are constants c1, c2 > 0 and n0 such that c1 · g(n) ≤ f(n) ≤ c2 · g(n) for all n ≥ n0.
Equivalently, f(n) = Θ(g(n)) exactly when f(n) = O(g(n)) and f(n) = Ω(g(n)).
| Notation | Meaning | Rough analogy |
|---|---|---|
| O(g) | Upper bound | f ≤ g |
| Ω(g) | Lower bound | f ≥ g |
| Θ(g) | Tight bound | f = g |
The analogy is about growth rate only. It ignores constant factors.
Checking a tight bound
Take f(n) = 3n² + 5n. We claim f(n) = Θ(n²).
- Lower bound: 3n² + 5n ≥ 3n² for all n ≥ 1, so c1 = 3.
- Upper bound: 3n² + 5n ≤ 4n² exactly when 5n ≤ n², which holds for n ≥ 5. So c2 = 4 and n0 = 5.
The following script confirms the inequality over a range of values. A finite check is not a proof, but it catches wrong constants.
def f(n):
return 3 * n * n + 5 * n
for n in range(5, 1001):
assert 3 * n * n <= f(n) <= 4 * n * n
print("3n^2 <= f(n) <= 4n^2 holds for n = 5..1000")Common mistakes
Many people read O as "worst case" and Ω as "best case". That is wrong. A bound describes a function, and a case selects which function you are bounding. The next chapter covers cases in detail.
Consider has_duplicate from earlier in this tutorial:
- Worst case (no duplicates): n(n-1)/2 comparisons, which is Θ(n²).
- Best case (first two items equal): one comparison, which is Θ(1).
Each case has its own tight bound. You can also say the worst case is O(n²) and Ω(n²). Both statements are true, and together they give Θ(n²).
Some functions have a single tight bound for every input. total always runs its loop n times, so its running time is Θ(n) in all cases.
When to use each
- Use O to promise a ceiling, such as "never slower than n log n".
- Use Ω to state a floor. For example, any comparison-based sort must do Ω(n log n) comparisons in the worst case, so no such algorithm can beat that.
- Use Θ when the upper and lower bounds meet. It is the most informative statement.
A function with no matching bounds has no Θ. For example, a running time that is 1 on even n and n on odd n is O(n) and Ω(1), but it has no single Θ bound that covers every n.
Exercise
Show that f(n) = 2n + 10 is Θ(n) by giving constants c1, c2, and n0 that satisfy the definition.
Show answer
Choose c1 = 2, c2 = 3, n0 = 10. For n ≥ 10, 2n ≤ 2n + 10 always holds, and 2n + 10 ≤ 3n because 10 ≤ n. So 2n ≤ f(n) ≤ 3n for all n ≥ 10, which gives f(n) = Θ(n).