Big-O is an upper bound and may be loose
n = O(n²) is true and uninformative. "Is O(n²)" does not mean "grows like n²".
f(n) = O(g(n)) asserts the existence of a constant C and a threshold k with f(n) ≤ Cg(n) beyond k. Proving it means producing them; that is the entire content of the definition.
Core ideas
Each of the three is an existence claim, and each is proved by exhibiting the witnesses.
n = O(n²) is true and uninformative. "Is O(n²)" does not mean "grows like n²".
Both bounds. It is what should be claimed when the growth is actually known, and the one people usually mean when they say O.
A C and a k that work. Anything else is a restatement of the claim.
The material
Definitions, worked proofs, and the properties that shorten later work.
f(n) = O(g(n)) means there are constants C > 0 and k such that |f(n)| ≤ C|g(n)| for every n ≥ k. The pair (C, k) is a witness.
f(n) = Ω(g(n)) means |f(n)| ≥ C|g(n)| for some C > 0 and all n ≥ k. f(n) = Θ(g(n)) means both, so f and g grow at the same rate.
The = is traditional and misleading: these are set memberships, and O(g) is the class of functions bounded above by a multiple of g. f(n) = O(g(n)) should be read "f is in O(g)", and it is not symmetric.
For n ≥ 1 we have n ≤ n² and 1 ≤ n², so 3n² + 5n + 100 ≤ 3n² + 5n² + 100n² = 108n². The witnesses are C = 108 and k = 1. Sharper choices exist — at n ≥ 10, C = 5 works — and any valid pair proves the claim.
Suppose n² ≤ Cn for all n ≥ k. Dividing by n gives n ≤ C for all n ≥ k, which is false for n > max(C, k). No pair of witnesses exists.
That is the shape of a disproof: assume witnesses and derive a contradiction. It is a direct proof of a negation, and “Contraposition and Contradiction” in Logic and Proof is the technique.
The last line is why the base of a logarithm is never written in a complexity class: log₂ n and log₁₀ n differ by the constant factor log₂ 10, which Θ discards.
The sum rule is what makes analysis of straight-line code easy: a sequence of blocks costs the maximum of their costs, not the sum, in asymptotic terms.
"Quicksort is O(n log n)" is a widespread and false statement: quicksort's worst case is Θ(n²). What is true is that its average case is Θ(n log n). Big-O is an upper bound and quoting it without saying which case is being bounded loses the distinction the notation exists to express.
Similarly "at least O(n)" is meaningless — O is already an upper bound — and "Ω" is the word wanted there.
Interactive
Counts from running, not from quoting
Method
Bound each term, then collect.
For n ≥ 1, lower powers are bounded by higher ones. That is usually the whole argument.
Any valid C proves the claim. Optimising it is not required and rarely worth the effort.
The bound need only hold beyond it, which is what lets small-n behaviour be ignored.
Divide through by g(n) and show the resulting bound on n is impossible.
One positive, one negative.
The first proof produced a specific pair, which is what the definition asks for. The second assumed a pair existed and refuted it. Every big-O argument on this course has one of these two shapes.
Prove 5n³ + 2n² + n = O(n³) by exhibiting a C and a k (C = 8, k = 1 is one pair), and then prove n³ ≠ O(n²) by contradiction: divide the supposed bound through by n². The two shapes cover almost every claim you will meet.
Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.
No recommendations yet for this lesson.