3.1.1 · D1Complexity Analysis

Foundations — Big-O notation — formal definition, mathematical

2,832 words13 min readBack to topic

This page assumes nothing. Every squiggle on the parent note — , , , , , , even the phrase "grows faster" — is built here from the ground up, in the order that lets each piece rest on the one before it.


0. What is a "function"? (the object we measure)

The picture: a box with an arrow going in (labelled ) and an arrow coming out (labelled ).

In complexity analysis the input is the size of the problem (how many items to sort, how long the list is) and the output is the cost (how many steps the algorithm takes). So is not an abstract toy — it is the answer to "how much work for a problem of size ?"

Figure — Big-O notation — formal definition, mathematical

1. The symbols and (what goes in, what comes out)

Input sizes are counting numbers — you can have a list of items or items, but never items. That is why the parent writes : the input lives in . This is exactly why the graph in Section 0 is a set of dots, not a continuous curve — the domain has gaps.

Cost is never negative (an algorithm can't take steps), and it can be any size, so the output lives in .


2. The symbol (staying below)

For two curves, at a single input means the -dot is at or below the -dot at that horizontal position. Big-O will ask for this " below " to hold not at one point but for every input dot past a threshold — that is the heart of the definition.


3. Constants, multipliers, and the symbol (scaling a curve)

The picture: take the curve and pull it upward. With every height doubles; the shape is identical, just taller. This stretch is exactly what lets us ignore constant factors — if runs times slower than but has the same shape, we pick and tucks neatly under .

Figure — Big-O notation — formal definition, mathematical

4. The threshold (ignoring the small stuff)

The picture: draw a vertical line at . Everything right of that line is the region Big-O looks at; everything left of it (the small inputs) is crossed out.

Figure — Big-O notation — formal definition, mathematical

5. The quantifiers and "for all" (the grammar of the definition)

The parent's definition says: "there exist constants such that for all " Two logic words, two jobs.


6. The symbol and "grows faster" (the long run)

The picture: two sets of dots both climbing, but the steeper one pulling away and never being caught. That "never caught even after stretching" is the ratio racing to .


7. Putting it together: reading the definition symbol-by-symbol

Now every piece is earned, so the parent's definition becomes plain English.


Equipment checklist

Test yourself — cover the right side and answer before revealing.

What is a function in complexity terms?
A machine taking input size and returning the cost (number of steps).
Why is the graph of really a set of dots, not a solid curve?
The domain is (only ); is defined at isolated integer points, so any connecting line is just a visual aid.
What set do input sizes live in, and why?
(counting numbers ) — you can't have a fractional number of items.
What set do costs live in, and why?
— cost is a real number that is never negative.
What type of number is the constant ?
A positive real, — it need not be a whole number.
What does mean geometrically?
The -dot sits at or below the -dot stretched vertically by factor .
Why must ?
A zero or negative stretch could never sit above a positive cost curve.
Why do we implicitly need past ?
If then can't bound a positive ; the yardstick must stay strictly positive.
What does the threshold let us ignore?
The messy small-input region where dots cross unpredictably; we study only (and often take to keep positive).
Does have to be the smallest working value?
No — any working proves the claim; existence, not minimality.
What does demand of you?
Find just one pair that works — a single witness suffices.
What does "for all " demand?
The inequality must hold at every input past the threshold, no exceptions.
Why can not change as grows?
You fix up front; a fixed getting overtaken by growing is exactly what disproves a Big-O claim.
Why is "" an abuse of notation, and what is precise?
is a set of functions; the precise statement is the membership , which (unlike ) is not symmetric.
Is a real number you can plug in?
No — denotes the unbounded process " passes any wall"; you never evaluate .
How do you make " grows faster than " precise?
The ratio test: means grows strictly faster (so ).

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
  • Time Complexity vs Space Complexity
  • Asymptotic growth rates ordering
  • Master Theorem
  • Limits and infinity (Calculus)