Intuition The one core idea
Big-O is a way to compare how two functions grow when their input gets huge, while deliberately ignoring constant multipliers and small inputs. Everything on the parent page is machinery for making one sentence precise: "f eventually stays below some fixed multiple of g ."
This page assumes nothing . Every squiggle on the parent note — f , g , N , ≤ , → ∞ , ∃ , 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.
A function is a machine: you feed it one number in, it spits one number out. We write f ( n ) to mean "the output of machine f when the input is n ."
The picture: a box with an arrow going in (labelled n ) and an arrow coming out (labelled f ( n ) ).
In complexity analysis the input n is the size of the problem (how many items to sort, how long the list is) and the output f ( n ) is the cost (how many steps the algorithm takes). So f is not an abstract toy — it is the answer to "how much work for a problem of size n ?"
Intuition Why we draw functions as dots, not a solid curve
A single number f ( 50 ) tells you the cost at one input. But Big-O is about scaling — what happens across all input sizes. So we plot n on the horizontal axis and f ( n ) on the vertical axis. But watch out: n is a counting number (Section 1), so f ( n ) only truly exists at n = 0 , 1 , 2 , 3 , … — it is defined at isolated dots , not at every real point in between. There is no such thing as "f ( 3.5 ) " when n counts items. We often draw a smooth line through the dots just to make the trend visible to the eye — but that line is a reading aid, not part of the function. Keep the dots in mind: the growth "shape" is the pattern those dots trace as they march rightward.
N — the natural numbers
N is the set of counting numbers: 0 , 1 , 2 , 3 , … The picture is evenly spaced dots marching off to the right, forever.
Input sizes are counting numbers — you can have a list of 0 items or 7 items, but never 3.5 items. That is why the parent writes f : N → … : the input lives in N . This is exactly why the graph in Section 0 is a set of dots , not a continuous curve — the domain has gaps.
R ≥ 0 — non-negative real numbers
R is every point on a continuous number line. The superscript ≥ 0 keeps only the points at or right of zero : 0 , 0.5 , 1 , π , 1000 , …
Cost is never negative (an algorithm can't take − 3 steps), and it can be any size, so the output lives in R ≥ 0 .
→ in f : N → R ≥ 0
Read f : A → B as "f is a machine that takes inputs from A and returns outputs in B ." Here: takes a counting number, returns a non-negative real. Note the asymmetry : inputs are discrete dots (N ), outputs may be any real height (R ≥ 0 ).
→ always means 'approaches'."
Why it feels right: you'll soon meet n → ∞ which does mean "approaches."
The fix: the arrow has two jobs . In f : N → R ≥ 0 it means "from-set to to-set" (the type of the machine). In n → ∞ (Section 6) it means "let n grow endlessly." Same arrow, different sentence — context tells you which.
Definition Less-than-or-equal,
≤
a ≤ b means "a is not bigger than b " — either smaller, or exactly equal. On the number line, a sits at or to the left of b .
For two curves, f ( n ) ≤ g ( n ) at a single input n means the f -dot is at or below the g -dot at that horizontal position . Big-O will ask for this "f below g " to hold not at one point but for every input dot past a threshold — that is the heart of the definition.
Intuition Why one-sided (
≤ ) and not = ?
If we demanded f ( n ) = g ( n ) we'd need the cost to match exactly — impossibly strict, and machine-dependent. Demanding only f ( n ) ≤ c g ( n ) asks the far weaker, far more useful question: "does f stay underneath some scaled copy of g ?" Big-O is an upper bound precisely because its inequality points one way.
A constant is a number that does not change as n changes — it is fixed once and never moves. Contrast with n , which is a variable : it takes every value 0 , 1 , 2 , …
Definition The multiplier
c
In Big-O, c is a chosen real constant with c > 0 — that is, c ∈ R + (a positive real, so c may be 4 , or 0.5 , or 3 7 ; it need not be a whole number). We multiply the whole g -curve by it. c g ( n ) is the curve g stretched vertically by factor c .
The picture: take the g curve and pull it upward. With c = 2 every height doubles; the shape is identical, just taller. This stretch is exactly what lets us ignore constant factors — if f runs 100 times slower than g but has the same shape , we pick c = 100 and f tucks neatly under c g .
c > 0 and never c ≤ 0
If c = 0 then c g ( n ) = 0 everywhere — nothing positive could ever stay below it. If c < 0 the stretched curve flips below the axis, but costs are non-negative, so it could never bound them. Only a positive real stretch makes sense.
Common mistake "The bound works even if the yardstick
g ( n ) hits zero."
Why it feels right: we rarely check g itself.
The fix: for c g ( n ) to bound a positive cost, we implicitly need g ( n ) > 0 for all n ≥ n 0 . If g ( n ⋆ ) = 0 at some point past the threshold, then c g ( n ⋆ ) = 0 , and no positive f ( n ⋆ ) can satisfy f ≤ c g there. This is why standard growth yardsticks (n , n 2 , log n for n ≥ 2 , 2 n , …) are chosen to be strictly positive once n is large. The threshold n 0 (next section) is also our chance to step past any early zeros of g .
n 0
n 0 is a fixed input value that marks a starting line . We only care about what happens for inputs n ≥ n 0 — everything to the left of n 0 is ignored.
The picture: draw a vertical line at n 0 . Everything right of that line is the region Big-O looks at; everything left of it (the small inputs) is crossed out.
Intuition Why we throw away small inputs
For tiny n , the dots cross each other unpredictably — an O ( n 2 ) routine can beat an O ( n ) routine at n = 3 because of setup overhead. That crossing tells you nothing about scaling . By starting at n 0 , we skip the messy early wiggles and study only the long-run behaviour, where the true growth shape reveals itself. Choosing n 0 ≥ 1 also conveniently keeps us away from n = 0 , which matters the moment we want to divide by n (Section 7).
n 0 must be the smallest value that works."
Why it feels right: it feels tidy to find the exact crossover point.
The fix: any threshold that works proves the claim. The definition asks whether some n 0 exists, not the smallest one. Pick whatever makes your algebra painless (often n 0 ≥ 1 , to keep n positive).
The parent's definition says: "there exist constants c , n 0 such that for all n ≥ n 0 … " Two logic words, two jobs.
∃ — "there exists"
∃ c means "you can find at least one value of c that works." You are hunting for a single witness; one success is enough.
∀ )
"for all n ≥ n 0 " means "every single input past the threshold must obey the inequality — no exceptions allowed."
Intuition Why the order matters: find
c , n 0 FIRST, then test all n
The definition reads "there exist c ∈ R + and n 0 such that for all n …" . This means: you lock in one c and one n 0 up front , and then that single pair must handle every large n . You are not allowed to change c as n grows. This is exactly why n 2 = O ( n ) : any fixed c eventually gets overtaken (Section 7).
n → ∞
Read "n tends to infinity" as "let n get larger and larger without ever stopping." Crucially, ∞ is not a real number — you cannot plug it in as "f ( ∞ ) ." It is shorthand for a process : "pick any bound you like, and n eventually passes it." The picture is the dots of n marching off the right edge of the page, never halting. The full machinery lives in Limits and infinity (Calculus) ; for now hold the intuition — "no matter how big a wall you build, n walks past it."
f grows faster than g " — made precise with a ratio
Informally: once n is huge, f pulls away from g and no constant stretch of g catches it. To make this precise we look at the ratio g ( n ) f ( n ) (valid because g ( n ) > 0 , Section 3) and ask what it does as n → ∞ :
lim n → ∞ g ( n ) f ( n ) = ∞ ⟺ f grows strictly faster than g .
Read it: "the ratio blows up without bound." If instead the ratio settles to a finite number, f and g grow at the same rate (up to a constant), and then f ∈ O ( g ) .
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 ∞ .
Intuition Why "faster" and "
O " are opposites
f ∈ O ( g ) says f grows no faster than g — its ratio to g stays bounded , so a single constant stretch c g holds it down. If f grows strictly faster (g f → ∞ ), no fixed c can cap the ratio, so f ∈ / O ( g ) . The disproof recipe below (n 2 ∈ / O ( n ) ) is exactly this ratio test made algebraic: n n 2 = n → ∞ .
Now every piece is earned, so the parent's definition becomes plain English.
f = O ( g ) is an equation."
Why it feels right: the "= " sign is right there, and everyone writes it that way.
The fix: O ( g ) is really a set — the collection of all functions that grow no faster than g . The precise statement is the membership f ∈ O ( g ) , i.e. "f is one of the functions in that collection." The customary "f = O ( g ) " is an abuse of notation we tolerate for brevity; it does not mean f equals a single thing, and (as the parent warns) it is not symmetric — you may never flip it to "O ( g ) = f ." Throughout this page we prefer f ∈ O ( g ) when precision matters.
Worked example Watch the machinery run: is
3 n + 7 ∈ O ( n ) ?
f ( n ) = 3 n + 7 (the cost), g ( n ) = n (the yardstick, strictly positive for n ≥ 1 ).
Pick c = 4 ∈ R + (a stretch, Section 3) and n 0 = 7 (a starting line, Section 4).
For every n ≥ 7 : since 7 ≤ n , we get 3 n + 7 ≤ 3 n + n = 4 n = c g ( n ) . ✓
We found one pair (∃ ) that works for all large n (for all). So yes, 3 n + 7 ∈ O ( n ) .
Worked example Watch it FAIL: is
n 2 ∈ O ( n ) ?
Suppose some fixed c worked with some threshold n 0 . First insist n 0 ≥ 1 so that every n ≥ n 0 satisfies n > 0 — this is what makes the next step legal. Then n 2 ≤ c n for all such n ; dividing by n > 0 (safe precisely because n 0 ≥ 1 ) gives n ≤ c . But n → ∞ (Section 6) while c is frozen (Section 3) — once n > c the inequality dies. Equivalently, the ratio n n 2 = n → ∞ , so no c can cap it. No single c survives all n , so no witness exists: n 2 ∈ / O ( n ) .
Test yourself — cover the right side and answer before revealing.
What is a function f ( n ) in complexity terms? A machine taking input size n and returning the cost (number of steps).
Why is the graph of f ( n ) really a set of dots, not a solid curve? The domain is N (only 0 , 1 , 2 , … ); f is defined at isolated integer points, so any connecting line is just a visual aid.
What set do input sizes n live in, and why? N (counting numbers 0 , 1 , 2 , … ) — you can't have a fractional number of items.
What set do costs f ( n ) live in, and why? R ≥ 0 — cost is a real number that is never negative.
What type of number is the constant c ? A positive real , c ∈ R + — it need not be a whole number.
What does f ( n ) ≤ c g ( n ) mean geometrically? The f -dot sits at or below the g -dot stretched vertically by factor c .
Why must c > 0 ? A zero or negative stretch could never sit above a positive cost curve.
Why do we implicitly need g ( n ) > 0 past n 0 ? If g ( n ) = 0 then c g ( n ) = 0 can't bound a positive f ( n ) ; the yardstick must stay strictly positive.
What does the threshold n 0 let us ignore? The messy small-input region where dots cross unpredictably; we study only n ≥ n 0 (and often take n 0 ≥ 1 to keep n positive).
Does n 0 have to be the smallest working value? No — any working n 0 proves the claim; existence, not minimality.
What does ∃ c , n 0 demand of you? Find just one pair ( c , n 0 ) that works — a single witness suffices.
What does "for all n ≥ n 0 " demand? The inequality must hold at every input past the threshold, no exceptions.
Why can c not change as n grows? You fix c up front; a fixed c getting overtaken by growing n is exactly what disproves a Big-O claim.
Why is "f = O ( g ) " an abuse of notation, and what is precise? O ( g ) is a set of functions; the precise statement is the membership f ∈ O ( g ) , which (unlike = ) is not symmetric.
Is ∞ a real number you can plug in? No — ∞ denotes the unbounded process "n passes any wall"; you never evaluate f ( ∞ ) .
How do you make "f grows faster than g " precise? The ratio test: lim n → ∞ f ( n ) / g ( n ) = ∞ means f grows strictly faster (so f ∈ / O ( g ) ).
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)