Sub topic 7
Big Omega and Big Theta: Lower and Tight Bounds
This chapter assumes you know the formal definition of Big O (constants c and n0), how to drop constants and lower-order terms, and how to read the complexity of simple loops. Big O only says "no worse than." Big Omega and Big Theta supply the other two statements you need: "no better than" and "exactly this rate."
Why Big O alone is not enough
Suppose someone says an algorithm is O(n²). That statement is true of a linear-time algorithm too, because n ≤ n² for n ≥ 1. Big O is an upper bound, and an upper bound can be loose. It cannot tell you whether the algorithm is actually slow.
To say how fast a function grows, you need a bound from below as well. Big Omega gives the lower bound. Big Theta combines the two into a tight bound.
Big Omega: a lower bound
A function f(n) is Ω(g(n)) if there are constants c > 0 and n0 such that
f(n) ≥ c · g(n) for all n ≥ n0.
This is the Big O definition with the inequality reversed. For large n, f stays above a constant multiple of g.
For example, 3n² + 5n + 7 is Ω(n²). Take c = 3 and n0 = 1. Then 3n² + 5n + 7 ≥ 3n², because the extra terms are positive.
Big Theta: a tight bound
A function f(n) is Θ(g(n)) if there are constants c1 > 0, c2 > 0, and n0 such that
c1 · g(n) ≤ f(n) ≤ c2 · g(n) for all n ≥ n0.
The function is sandwiched between two scaled copies of g. Equivalently, f is Θ(g) exactly when f is both O(g) and Ω(g).
| Notation | Meaning | Rough analogy | Bound type |
|---|---|---|---|
| O(g(n)) | f grows no faster than g | f ≤ g | Upper |
| Ω(g(n)) | f grows no slower than g | f ≥ g | Lower |
| Θ(g(n)) | f grows at the same rate as g | f = g | Tight |
The analogy is only about growth rates, not exact values. Constant factors are ignored in all three.
A worked proof
Show that f(n) = 3n² + 5n + 7 is Θ(n²).
Upper bound. For n ≥ 1 we have n ≤ n² and 1 ≤ n². So
3n² + 5n + 7 ≤ 3n² + 5n² + 7n² = 15n².
This gives c2 = 15 and n0 = 1.
Lower bound. For n ≥ 1, 3n² + 5n + 7 ≥ 3n². This gives c1 = 3.
With c1 = 3, c2 = 15, and n0 = 1, the definition is satisfied, so f(n) = Θ(n²).
Now test a wrong claim: f(n) = Ω(n³). That would need 3n² + 5n + 7 ≥ c · n³ for all large n. Divide by n³ and you need c ≤ 3/n + 5/n² + 7/n³. The right side shrinks toward 0 as n grows, so no positive constant c works. The claim is false. Meanwhile f(n) = O(n³) is true, but it is not tight.
Checking bounds numerically
You can sanity-check chosen constants by computing the inequality over a range of n. This is a check, not a proof, because it cannot cover every n. It does catch most arithmetic mistakes in your constants.
def check_theta(f, g, c1, c2, n0, n_max=10_000):
"""Return True if c1*g(n) <= f(n) <= c2*g(n) for n0 <= n <= n_max."""
return all(c1 * g(n) <= f(n) <= c2 * g(n) for n in range(n0, n_max + 1))
def f(n):
return 3 * n**2 + 5 * n + 7
print(check_theta(f, lambda n: n**2, c1=3, c2=15, n0=1)) # True
print(check_theta(f, lambda n: n**3, c1=1, c2=15, n0=1)) # False: lower bound fails
print(check_theta(f, lambda n: n**2, c1=3, c2=4, n0=1)) # False: c2 = 4 is too smallThe second call fails because n² is not above c · n³. The third fails for small n: at n = 1, f(1) = 15, but 4 · 1 = 4. Constants that are too tight are a common reason a bound "fails."
Bounds are not cases
A very common mistake is to match the notations to best, worst, and average case: O for worst, Ω for best, Θ for average. This is wrong.
Big O, Ω, and Θ describe how a single function grows. A case describes which function you are measuring. Each case has its own cost function, and each of those functions can be bounded with any of the three notations.
Take linear search. It scans a list and stops when it finds the target.
def linear_search(items, target):
comparisons = 0
for i, x in enumerate(items):
comparisons += 1
if x == target:
return i, comparisons
return -1, comparisons
data = list(range(8))
print(linear_search(data, 0)) # (0, 1) target is first
print(linear_search(data, 7)) # (7, 8) target is last
print(linear_search(data, 99)) # (-1, 8) target is missingHere the cost functions are:
- Best case: 1 comparison for every n, so Θ(1).
- Worst case: n comparisons, so Θ(n).
Both of those are tight bounds. Applying Θ to the worst case is perfectly legitimate: "the worst case is Θ(n)" means the worst-case cost grows linearly, not faster and not slower.
For the algorithm as a whole, with no case specified, you can say:
- The running time is O(n), since no input costs more than n comparisons.
- The running time is Ω(1), since every input costs at least one comparison.
- There is no single Θ that covers all inputs. The cost ranges from constant to linear depending on the input.
The next chapter treats best, worst, and average case in detail. For now, remember that the case picks the function and the notation describes its growth.
Quick facts and properties
- Symmetry of Θ. If f is Θ(g), then g is Θ(f).
- Transitivity. If f is O(g) and g is O(h), then f is O(h). The same holds for Ω and Θ.
- Duality. f is O(g) exactly when g is Ω(f).
- Polynomials. A polynomial of degree k with a positive leading coefficient is Θ(n^k). This is why dropping lower-order terms is safe.
- Logarithm bases. log₂ n and log₁₀ n differ by a constant factor, so Θ(log₂ n) = Θ(log₁₀ n). The base is usually left out.
Not every pair of functions is comparable. For example, n and n^(1 + sin n) oscillate against each other, so neither is O of the other. This is rare in algorithm analysis, but it means "f is O(g) or Ω(g)" is not guaranteed for arbitrary functions.
Lower bounds on problems
So far the bounds described one algorithm. You can also state a lower bound on a problem: no algorithm in a given model can solve it faster. A well-known example is that any sorting algorithm that works only by comparing pairs of elements needs Ω(n log n) comparisons in the worst case. This is why merge sort, which runs in O(n log n), is considered optimal among comparison sorts. When an algorithm's upper bound matches the problem's lower bound, you cannot improve it asymptotically within that model.
Common errors
- Using O when you mean Θ. Saying "binary search is O(n²)" is true but useless. If you know the rate, state the tight bound.
- Treating Ω as "best case." Ω is a lower bound on some function. You can state an Ω bound on the worst case too, such as "the worst case is Ω(n)."
- Assuming Θ exists for the whole algorithm. If best and worst cases grow at different rates, only the separate cases have tight bounds.
- Forgetting the quantifier. The definitions require the inequality for all n ≥ n0, not just for some n. A single large input where the inequality holds proves nothing.
- Proving with too few constants. Θ needs two constants, c1 and c2. Proving only one side gives O or Ω, not Θ.
Exercises
Exercise
Show that f(n) = 4n + 10 is Θ(n). Give explicit values for c1, c2, and n0.
Show answer
For n ≥ 10, 10 ≤ n, so 4n + 10 ≤ 4n + n = 5n. That gives c2 = 5 and n0 = 10. For every n ≥ 1, 4n + 10 ≥ 4n, so c1 = 4. With c1 = 4, c2 = 5, and n0 = 10, 4n ≤ 4n + 10 ≤ 5n for all n ≥ n0, so f(n) = Θ(n). Other valid choices exist, for example c2 = 14 with n0 = 1.
Exercise
A function has best-case cost Θ(1) and worst-case cost Θ(n). Which of these statements are true for the algorithm overall: (a) O(n), (b) Ω(1), (c) Θ(n), (d) Ω(n)?
Show answer
(a) and (b) are true. No input costs more than a linear amount, and every input costs at least a constant amount. (c) and (d) are false for the algorithm as a whole, because the best-case inputs cost only a constant, so the running time is not bounded below by a linear function over all inputs. Statements (c) and (d) would be true if restricted to the worst case.
Exercise
Is n² = Ω(n log n)? Is n log n = Ω(n²)? Explain briefly.
Show answer
Yes to the first. For n ≥ 1, log n ≤ n, so n log n ≤ n², which means n² ≥ 1 · (n log n) and n² is Ω(n log n). No to the second. The ratio (n log n) / n² = (log n) / n goes to 0, so n log n cannot stay above c · n² for any positive c at large n.