3.1.1 · D3Complexity Analysis

Worked examples — Big-O notation — formal definition, mathematical

2,987 words14 min readBack to topic

The scenario matrix

Before solving, let us name the shapes of problem that exist. Every worked example below is tagged with the cell it hits.

Cell Case class What makes it different Example that covers it
A Linear + constant Small term absorbed into big term Ex 1
B Polynomial, several terms Push every low power up to the top Ex 2
C Loose upper bound (true but not tight) grows strictly slower than Ex 3
D Disproof (no exist) Ratio , contradiction Ex 4
E Degenerate / zero-ish input somewhere, or constant Ex 5
F Logarithm & log-vs-power New tool: grows slower than any Ex 6
G Exponential vs polynomial (limiting) Growth-rate showdown at infinity Ex 7
H Real-world word problem Translate code/story into Ex 8
I Exam twist (sum & product rules) Combine two bounds correctly Ex 9
Figure — Big-O notation — formal definition, mathematical

The figure above is the map we return to in Ex 3: any curve above is a valid Big-O ceiling. The tight ceiling (, chalk-blue) hugs with a gap that stays proportional; the loose ceiling (, chalk-pink) sits above with a gap that explodes. Both are true Big-O statements — that is the whole subtlety this page drills. Look at how the pink gap widens in the figure while the blue gap does not; that picture is the difference between "loose" and "tight."


Ex 1 — Cell A: linear plus a constant


Ex 2 — Cell B: a full polynomial


Ex 3 — Cell C: a loose but true bound


Ex 4 — Cell D: disproving a claim


Ex 5 — Cell E: degenerate / constant / zero inputs


Ex 6 — Cell F: logarithms enter


Ex 7 — Cell G: exponential vs polynomial (limiting behaviour)


Ex 8 — Cell H: a real-world word problem


Ex 9 — Cell I: exam twist (sum & product rules together)


Recall

Recall Which cell needs a

raised and why? Cell E (degenerate). If where , the bound is impossible there, so push past that point. ::: Raise the threshold above any degenerate input.

Recall Disproof recipe in one line

Show the ratio ; then no constant can cap under . ::: Ratio diverges ⇒ not Big-O.

Recall Sum rule vs product rule

For the sum, keep the maximum term (). For the product, multiply the two ceilings (). ::: Max for sums, multiply for products.


Connections

  • Parent: Big-O — formal definition (mathematical)
  • 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)

Case Map

true

false

Function f of n given

Prove or disprove Big-O

Prove a bound

Disprove a bound

Flatten lower terms onto top power

Pick c and n0

Form ratio f over g

Ratio goes to infinity

No constant c exists

Sum rule keep max

Product rule multiply ceilings