3.1.1 · D5Complexity Analysis
Question bank — Big-O notation — formal definition, mathematical
Two pictures to hold in your head first
True or false — justify
Is ?
True — for , , so ; the constant absorbs everything and the lower-order term is dominated.
Is ?
True but loose — for , , so works; Big-O is an upper bound, so a function may be of something that grows strictly faster.
Is ?
False — would force for all large , impossible for a fixed as .
If , is it always true that ?
False — Big-O is directional like , not symmetric; holds but does not.
Is ?
True — logs of different bases differ only by the constant factor , which the multiplier absorbs; that is why we write with no base.
Is ?
True — , a constant multiple, so works; adding a constant to an exponent only rescales.
Is ?
False — , so the ratio ; no fixed caps it. Doubling the exponent is not a constant factor.
Is ?
False — factorials outgrow every fixed-base exponential; the ratio , so no constant caps it.
Is ?
True — a constant function is bounded by (take ); constants are , the class of "grows not at all."
Is ?
True — it oscillates between and , so it is bounded above by times ; boundedness, not smoothness, is what needs.
Is ?
True — for , , so ; works (using natural log).
Spot the error
" because is a huge polynomial." — where's the flaw?
Size at a fixed is irrelevant; what matters is the limit. As , , so any exponential eventually overtakes any polynomial. False.
" requires , the smallest threshold that works." — flaw?
The definition needs existence of some , not the minimal one; also proves it. Any valid pair suffices.
" means and have the same running time." — flaw?
It means grows no faster than , an upper bound; they can differ wildly (e.g. ). Same-order requires , see Big-Theta notation — tight bound.
"I dropped the constant, so — but is since I dropped ." — flaw?
You may drop the coefficient but not change the power; the constant absorbs , leaving , never . Dropping constants ≠ dropping the growth term.
" by the product rule." — flaw?
That is a sum, not a product; the sum rule gives . The product rule () applies only to multiplied factors.
"Since can fail at , the claim is broken." — flaw?
The bound need only hold for ; small- violations are exactly what lets us skip. Failure below the threshold does not disprove anything.
", so the sum is a different class." — flaw?
because the factor is absorbed by ; the sum of two linear costs is still linear.
Why questions
Why does the definition allow any rather than fixing ?
Because is what lets us ignore machine- and implementation-dependent coefficients; without a free , would not be and the notation would depend on hardware.
Why do we need at all instead of demanding the bound for all ?
Small inputs behave erratically (setup costs, one algorithm briefly beating another); lets us focus purely on scaling as , which is what we care about. See Limits and infinity (Calculus).
Why must be nonnegative for ?
The bound sandwiches between and ; if went negative, would too and the inequality would be impossible for any positive cost . Complexity functions count steps, so nonnegativity is natural.
Why is the inequality one-sided () rather than two-sided?
Big-O is only an upper bound; capturing a matching lower bound is the job of Big-Omega notation — lower bound, and both together give Big-Theta notation — tight bound.
Why is really an abuse of notation?
is a set of functions; the honest statement is . Writing "" tricks people into thinking it is symmetric, which it is not.
Why does the sum rule collapse to the maximum, ?
If and with , then ; the smaller term is swallowed by the dominant one. See Asymptotic growth rates ordering.
Why can Big-O never distinguish from but does distinguish from ?
is a constant multiple (absorbed by ), whereas is not bounded by any constant, so the growth shape genuinely differs.
Edge cases
If for all , is for any with for all large ?
Yes — holds trivially for any wherever is nonnegative; the zero function is of every nonnegative .
Is (a function big-O of itself)?
Yes — take : ; Big-O is reflexive, matching its ""-like nature.
Can at some points and still have ?
Only if is also wherever is, past ; if but there, then fails, so no works.
Is a decreasing function like still ?
Yes — it is bounded above by , so works; Big-O caps growth from above, and a shrinking function is trivially capped.
If and , what does that mean?
They bound each other both ways, so they have the same growth order — that is exactly ; see Big-Theta notation — tight bound.
Is (little-o) the same claim as ?
No — little-o demands the ratio (strictly smaller growth), while Big-O only demands it stay bounded; every is an , but not vice versa. See Little-o and little-omega.
Connections
- 3.1.01 Big-O notation — formal definition, mathematical (Hinglish)
- Big-Omega notation — lower bound
- Big-Theta notation — tight bound
- Little-o and little-omega
- Asymptotic growth rates ordering
- Time Complexity vs Space Complexity
- Master Theorem
- Limits and infinity (Calculus)