Reading Big-O Upper Bounds
A big-O upper bound limits growth up to a multiplicative constant once the input is large enough.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Check the definition once
For \(n\ge1\), \(3n+4\le7n\), so the operation count is \(O(n)\). It is also \(O(n^2)\), a less precise upper bound for this purpose. Start with a known count of operations.
State a tighter claim when available
The same expression is at least \(3n\). Combined with the upper bound, that gives \(\Theta(n)\). A bound of \(O(n)\) alone does not provide that lower bound. See best and worst cases for which input family such a count describes.[1]
Exhibit constants instead of comparing isolated measurements
For a nested triangular loop with \(T(n)=n(n+1)/2\), proving \(T(n)\le n^2\) for \(n\ge1\) gives a quadratic upper bound. The companion lower bound \(T(n)\ge n^2/2\) then gives a tight asymptotic order. Use a positive input size when dividing an inequality. See nested iteration.
n=4: T=10 and 8 ≤ 10 ≤ 16
n=8: T=36 and 32 ≤ 36 ≤ 64
T(n)
n² = (1 + 1/n)
2
Distinguish a bound from a precise classification
A quadratic sequence is also bounded above by a cubic function for large positive \(n\). Tightness requires that a matching lower bound hold. A strict lower growth rate can be ruled out by dividing by the competing function and showing the ratio grows without bound.