What is the difference between Big O and Big Theta
The difference between Big O and Big Theta is the difference between a ceiling and a measurement. Here is what each claims, worked on real step counts, and why almost everyone says Big O when they mean Big Theta.
The difference between Big O and Big Theta is that Big O promises only an upper bound on growth, while Big Theta promises the growth is pinned from above and below. Every Θ(n) function is also O(n), but not the reverse. Most people say Big O and mean Big Theta.
What does Big O actually claim?
Big O claims that a function grows no faster than another one, up to a constant factor and beyond some starting size. Formally, f(n) is O(g(n)) if there exist constants c and n0 such that f(n) ≤ c·g(n) for every n ≥ n0. That is the entire definition, and each piece of it is doing work.
Take f(n) = 3n² + 10n + 5, the exact step count of an imaginary routine. I claim f is O(n²). To prove it I need a c and an n0. Pick c = 4 and n0 = 11. At n = 11, f is 363 + 110 + 5 = 478, and 4n² is 484, so the inequality holds. It keeps holding because the difference 4n² - f(n) = n² - 10n - 5 only grows once n passes 5. Done: the claim is proven, and the proof took two numbers and one line of algebra.
Now notice what the definition does not say. It does not say f is close to n². The same f is also O(n³), O(n⁴), O(2ⁿ) and O(n!). Every one of those statements is true, because a ceiling can sit as far above the room as you like. Big O alone cannot tell you that you picked a bad ceiling.
What does Big Theta add that Big O does not?
Big Theta adds a floor. A function f is Θ(g(n)) when there are positive constants c1, c2 and n0 such that c1·g(n) ≤ f(n) ≤ c2·g(n) for all n ≥ n0. Equivalently, f is both O(g) and Ω(g), where Big Omega is the mirror image of Big O: a lower bound instead of an upper one.
Back to f(n) = 3n² + 10n + 5. The floor is trivial: 3n² ≤ f(n) for every n ≥ 1, so c1 = 3 works. The ceiling we already built with c2 = 4 and n0 = 11. Squeezed between 3n² and 4n², f is Θ(n²). Try the same with n³ and the floor fails: no constant c1 makes c1·n³ stay below 3n² + 10n + 5 forever, because n³ divided by n² grows without limit.
Here is the framing I use. Big O is the sign at the airline check-in desk: bags must weigh under 23 kg. A passenger carrying one sweater satisfies the sign perfectly, and you have learned nothing about the bag. Big Theta is the number on the scale, give or take a constant. The sign tells you whether a bag is allowed; the scale tells you what is in it. When a colleague says an algorithm is O(n²), ask yourself whether you just got the sign or the scale.
The numbers make the squeeze visible. Divide f(n) by n² at a few sizes:
- n = 10: f = 405, and 405 / 100 = 4.05
- n = 100: f = 31,005, and 31,005 / 10,000 = 3.1005
- n = 1,000: f = 3,010,005, and the ratio is 3.010005
The ratio settles toward 3. That convergence is what Θ(n²) feels like in practice: the shape of the curve is n², and only the constant is in doubt. Compare it with the true-but-loose claim O(n³). At n = 1,000, n³ is one billion, about 332 times the real count of 3,010,005. The ceiling holds, and it is useless as a prediction.
Why do people say Big O when they mean Big Theta?
They say Big O because upper bounds are what users care about (it will not be slower than this), and because the running time of an algorithm is usually not a single clean function of n. That second reason is the one nobody explains, and it is the real one.
Big Theta is a statement about one function. But the running time of an algorithm depends on the input itself, not just its size. Two arrays of length 1,000 can cost wildly different amounts. So before you can attach any notation, you must choose a slice of the behaviour: the worst case, the best case, or an average under some input distribution. Each slice is a proper function of n, and each can have its own O, Ω and Θ.
Insertion sort shows it. This version counts its own comparisons:
def insertion_sort(a):
comparisons = 0
for i in range(1, len(a)):
key = a[i]
j = i - 1
while j >= 0:
comparisons += 1
if a[j] <= key:
break
a[j + 1] = a[j]
j -= 1
a[j + 1] = key
return comparisonsFeed it an already sorted array of 1,000 elements. Each new element is compared once with its left neighbour, found to be in place, and the inner loop breaks: 999 comparisons. Feed it a strictly reversed array of 1,000. Element i must be compared against all i elements to its left, so the total is 1 + 2 + ... + 999 = 1000 · 999 / 2 = 499,500 comparisons. Same size, a 500-fold difference.
The best-case function is Θ(n). The worst-case function is Θ(n²). There is no single Θ for "the running time of insertion sort", because no one function sandwiches every input. What you can say about the algorithm as a whole is that it is O(n²) (nothing is worse than the worst case) and Ω(n) (nothing is better than the best case). That is why Big O became the default: it is the one notation that can cover an algorithm across all inputs without first picking a slice.
This also exposes the most common misconception. Big O is not "the worst case". The two are independent axes. Worst case answers which inputs you are measuring. O versus Θ answers whether you are bounding loosely from above or tightly from both sides. "The best case of insertion sort is O(n)" is a perfectly meaningful sentence, and so is "the worst case is Θ(n²)". Mixing the two axes is how people end up saying things like "Big O is the average case" in interviews.
How do the notations compare on a single function?
On a single function, O and Ω each accept a wide range of candidates, but Θ accepts exactly one growth rate. The table below tests several candidate bounds g(n) against f(n) = 3n² + 10n + 5.
| Candidate g(n) | f is O(g)? | f is Ω(g)? | f is Θ(g)? | What it tells you |
|---|---|---|---|---|
| n | No | Yes | No | Floor is far too low; f grows faster than linear |
| n log n | No | Yes | No | Still a floor only; f outgrows it |
| n² | Yes | Yes | Yes | The tight bound; ratio settles at 3 |
| n³ | Yes | No | No | True ceiling, 332 times too generous at n = 1,000 |
| 2ⁿ | Yes | No | No | True ceiling, no predictive value at all |
Read down the O column and you see a string of yeses once g is big enough. Read down the Ω column and you see them once g is small enough. Only one row survives both, and that row is the answer. A Θ claim is the only one that, by itself, lets a reader predict how the cost changes when the input doubles: it quadruples, give or take lower-order terms. An O claim alone lets them predict only that it will not be worse.
When does the distinction matter in practice?
It matters whenever the best and worst cases differ, and whenever someone is choosing between two algorithms that share an upper bound. A few real cases:
- Merge sort does Θ(n log n) work on every input of size n, so you can state the tight bound with no qualifiers. Saying it is O(n²) would be true and misleading.
- Quicksort with a naive pivot is Θ(n log n) on average and Θ(n²) in the worst case. The whole algorithm is O(n²) and Ω(n log n), and neither bound alone describes what you will see in production.
- Hash map lookup is Θ(1) in expectation but Θ(n) in the worst case when everything collides. Quoting "O(1)" without the word expected is quietly dropping a slice.
- Dynamic array append costs Θ(n) on the occasional resize and Θ(1) amortized across a long sequence. I covered how that averaging works in what is amortized time complexity.
There is a second trap, and it goes the other way. A Θ claim describes the shape of growth, not the speed at a size you care about. Imagine one algorithm that is Θ(n) with a constant of 50 per element, and another that is Θ(n log n) with a constant of 1. At n = 1,000,000, log₂ n is about 19.9, so the first costs roughly 50 million steps and the second about 19.9 million. The asymptotically worse algorithm wins. They only cross when log₂ n reaches 50, which is n = 2⁵⁰, about 10¹⁵. For any input you will ever hold in memory, the "slower" algorithm is faster. If you want the finer points of that kind of gap, O(log n) vs O(n log n) works through what the extra factor really costs.
So Big Theta is more precise than Big O about shape, and still silent about constants. Neither notation replaces measuring.
What should you actually say in an interview?
State the tight bound when you know it, name the case you mean, and fall back to Big O only when you cannot prove tightness. In practice that means sentences like "worst case Θ(n log n), and it does not depend on the input" or "O(n²) worst case, and I believe it is tight because of this input."
Take two sum on 10,000 numbers. The brute force checks every pair: 10,000 · 9,999 / 2 = 49,995,000 pair checks in the worst case, so it is Θ(n²) there. The hash map version does one pass with one lookup per element, 10,000 lookups, Θ(n) expected. If you only say "the first is O(n²) and the second is O(n)", an interviewer hears two ceilings. If you say "the first is quadratic in the worst case because the answer may be the last pair, the second is linear in expectation because each lookup is constant time on average", they hear two measurements. You can practice that phrasing on Two Sum and make the case split explicit every time.
A short habit I recommend: when you finish a solution, say the notation and the slice together, in that order. "Worst case, Θ(n)." "Average case, Θ(1) expected." "Overall, O(n log n)." If you catch yourself writing O(n²) for something you know is linear, you are not being safe. You are being vague, and vagueness is the one thing a complexity claim exists to remove.
One more position, since I promised to take them. Teaching Big O as the default and Big Theta as an academic footnote is backwards. Big Theta is the claim people actually mean, and the habit of checking whether your bound is tight is what stops you from shipping an analysis that is technically correct and practically empty.
Frequently asked questions
Is Big O the same as the worst case?
No. Worst case picks which inputs you measure; Big O is a kind of bound you place on whatever you measured. You can give a Big O for the best case, the average case or the worst case, and you can give a Big Theta for any of them as well.
Can an algorithm be both O(n) and O(n²)?
Yes, because Big O is only a ceiling and any larger growth rate is also a valid ceiling. A linear algorithm is O(n), O(n²) and O(n³) at once. The informative statement is the smallest ceiling you can prove, which is usually the Θ bound.
Should I say Big Theta in a coding interview?
Use it when you know the bound is tight and the case is clear, since it shows you understand the difference. If the interviewer asks for Big O, answer with Big O and mention that it is tight. A good way to rehearse that is to derive bounds for recurrences, which you can do with how to find the time complexity of a recursive function.