Intuition The ONE core idea
We want to describe how fast an algorithm's cost grows as the input gets huge — not its exact time, just the shape of the climb. To do that we trap the cost curve between two clean reference curves: a ceiling we never rise above (O ) and a floor we never sink below (Ω ); when the same shape works as both, the growth is pinned tight (Θ ).
This page assumes nothing . Before you meet Θ and Ω in the parent topic , every squiggle those definitions use gets built here from the ground up, in the order that each one depends on the last.
Before any symbol, here is the object everything else talks about.
Imagine you run an algorithm on inputs of size 1, 2, 3, … and for each size you write down how much work it does (how many steps, comparisons, or operations). Plot those dots: horizontal axis = input size, vertical axis = work done. Connect them and you get a curve that climbs .
n
Plain words: how big the input is — number of items to sort, length of a list, number of rows.
Picture: the horizontal axis . Bigger n = further right.
Why the topic needs it: complexity is a statement about what happens as n grows without limit , so n is the knob we turn all the way up.
f ( n )
Plain words: a rule that takes an input size and returns the amount of work. The letter f is just a name for "the function I'm studying"; f ( n ) means "f evaluated at size n ."
Picture: the height of the climbing curve at horizontal position n .
Why: this is the thing we want to classify. We rarely know f exactly — we only want its growth shape .
The single most-used piece of notation is writing f ( n ) , g ( n ) , c g ( n ) . If parentheses-after-a-letter is new, read this.
g ( n ) — a function of n
g is a name for a machine. You feed it a number n (that's what the parentheses hold), and it hands back another number.
Example: if g ( n ) = n 2 , then g ( 3 ) = 9 , g ( 10 ) = 100 .
Picture: another curve on the same axes as f — but g is a clean reference shape we already understand.
Intuition Why two functions,
f and g ?
f ( n ) is your messy algorithm's cost (maybe 3 n 2 + 5 n + 7 ). g ( n ) is a tidy yardstick like n , n 2 , or n log n . The whole topic is one question: "which yardstick does f 's curve match?" You cannot answer that with one curve alone — you need a reference to compare against.
The yardsticks g are always simple growth shapes. You must recognise them by eye .
n , n 2 , n 3
n (linear): double the input → double the work. A straight climbing line.
n 2 (quadratic): double the input → four times the work (2 2 ). Curves upward faster.
Picture: steeper and steeper bends as the exponent grows.
log n
Plain words: log 2 n answers ==“how many times can I halve n before I reach 1?”== So log 2 8 = 3 because 8 → 4 → 2 → 1 is three halvings.
Picture: a curve that climbs fast at first then almost flattens — it grows, but incredibly slowly .
Why the topic needs it: any algorithm that repeatedly halves its problem (binary search, balanced trees) has a log n factor. Sorting's famous floor is n log n .
Note: which base? For growth-shape purposes the base doesn't matter — log 2 n and log 10 n differ only by a constant factor, and constants get ignored (Section 5).
n log n
The product: for each of the n items you do log n work. Slightly steeper than the straight line n , far gentler than n 2 . This is the "good sorting" shape.
The definitions in the parent lean on two logic symbols. Here they are, in plain speech.
∀ — "for all"
Read the upside-down A as “for every.” ∀ n ≥ n 0 means "no matter which n you pick, as long as it's at least n 0 ."
Picture: a promise that holds at every point on the curve from some spot rightward.
∃ — "there exists"
Read the backwards E as “there is at least one.” ∃ c > 0 means "I can find some positive number c that works."
Picture: you get to choose one helper value; you only need it to exist, not to be unique.
Intuition Why this exact pairing "
∃ c … ∀ n "?
The order matters. "There exists a constant c such that for all large n …" means: pick c once, up front, and it must then work forever after. If you had to keep growing c as n grew, no single c exists — and that's precisely how we prove something is not O (see the parent's n 2 = O ( n ) example: n ≤ c would force c to beat every n ).
n 0 (n-naught) — the starting point
Plain words: the input size past which the rule kicks in. Below n 0 we don't care; from n 0 onward the bound must hold.
Picture: a vertical line on the axes. Everything left of it is ignored "warm-up"; the promise lives to its right.
Intuition Why ignore small
n ?
Real programs have startup quirks — a slow first iteration, a one-time table build. Those bumps live at small n and say nothing about the true growth. By only judging n ≥ n 0 , we throw away the baby-photo noise and study the grown-up trend. This is the whole meaning of the word asymptotic (see Asymptotic comparison of functions ): behaviour in the far-right limit, as n → ∞ .
Definition Scaling constant
c
Plain words: ==a fixed positive number we multiply the reference g by.== Writing c g ( n ) stretches the reference curve up (c > 1 ) or squashes it down (c < 1 ) — but never changes its shape .
Picture: the reference curve g , and a dashed copy of it lifted to c ⋅ g . Same silhouette, different height.
Intuition Why are we allowed to ignore constants?
A computer twice as fast turns cost f ( n ) into 2 1 f ( n ) — same shape, half the height. We don't want our classification to flip just because the hardware changed. So c absorbs constant factors: a 2 n 2 curve and a 100 n 2 curve are the same class , both Θ ( n 2 ) . The constant is a dial we deliberately refuse to read.
c do its job
Is 5 n 2 the same shape as n 2 ? Pick c = 5 : then 5 n 2 = c ⋅ n 2 exactly. One constant, done. The shape n 2 is identical; only the vertical dial differs.
With f , g , c , n 0 , ∀ , ∃ all built, the parent's definitions read cleanly. Here is what each one looks like on the axes.
O : your curve stays under the dashed reference — a lid.
Ω : your curve stays over the dashed reference — a floor.
Θ : your curve is squeezed between two dashed copies of the same reference — pinned to that shape.
That's the entire topic. Everything else (the limit shortcut, the worked examples) is machinery for finding the right g and the constants.
f = O ( g ) as ordinary equality
Why it tempts you: it's written with an equals sign.
The truth: here "= " means “is a member of the class.” It's one-directional: you write f = O ( g ) , never O ( g ) = f . Think of O ( g ) as the set of all functions that stay under c g , and "= " as "belongs to."
The one exception: Θ is symmetric — f = Θ ( g ) does imply g = Θ ( f ) , because being pinned to each other's shape works both ways.
compare curves as n grows
constant c ignore the dial
threshold n0 ignore small n
Each foundation on the left is a prerequisite for the sandwich definitions, which then split into O , Ω , and finally the tight Θ . If any left-hand box is fuzzy, the parent topic will feel like magic — go back and firm it up.
What does n stand for, and which axis is it? The input size; the horizontal axis. Bigger n = further right.
What is f ( n ) as a picture? The height of the climbing cost curve at input size n .
Why do we compare f against a second function g ? We can't name a growth shape from one curve alone; g is a clean yardstick (n , n 2 , n log n ) to match against.
What does log 2 n count? How many times you can halve n before reaching 1.
Does the log base matter for growth class? No — different bases differ only by a constant factor, which we ignore.
Read ∀ n ≥ n 0 in plain words. For every n at least as big as n 0 .
Read ∃ c > 0 in plain words. There is at least one positive number c (we get to pick it once).
Why must c be chosen before the ∀ n ? A single fixed c must work forever; if c had to keep growing with n , no such constant exists (that's how we disprove a bound).
What does n 0 let us ignore, and why? Small-n warm-up noise; the true growth shape only shows in the far-right trend.
What does the constant c let us ignore, and why? Constant factors (hardware speed, units) — they change height, not shape.
On the axes, what does O look like? Your curve staying under a dashed scaled copy of g (a lid).
On the axes, what does Ω look like? Your curve staying over a dashed scaled copy of g (a floor).
On the axes, what does Θ look like? Your curve squeezed between two dashed copies of g — pinned.
Is the "= " in f = O ( g ) real equality? No — it means "is a member of the class"; it's one-directional. Only Θ is symmetric.