Intuition The one core idea
Some questions are easy to check but seem hard to answer — like a maze you can verify a solution to instantly, yet solving from scratch feels slow. P vs NP asks whether that gap is real or just a gap in our cleverness; this page builds every word and symbol you need to even state that question.
This is the prerequisite page for the P vs NP topic . The parent note throws around n , O ( n k ) , "decision problem", "certificate", P ⊆ N P , and more. Here we earn every one of those from zero, in the order they build on each other.
Definition Zeroth word: algorithm
An algorithm is a finite, fixed recipe of unambiguous steps that turns an input into an output — like a cooking recipe a machine can follow with no guessing. Our machine is the Turing machine : it reads and writes single symbols on a paper tape, one square at a time. When we later "count steps", a step means one such basic tape action (read a square, write a square, move left/right). Fixing this machine model is what makes "number of steps" a precise, honest number rather than a vague feeling.
Definition One convention for the whole page: worst-case
Every time we say "runs in O ( n k ) time" or "polynomial time", we mean the worst case — the most steps the algorithm could take over all inputs of size n . Not the average input, not the luckiest input: the worst one. This is the standard used throughout complexity theory, and it's what "guaranteed fast" must mean — a promise that holds no matter what input arrives.
Mnemonic A note on the coloured
highlighting
Throughout this page, coloured highlighting marks a key term being defined — it is purely typographic emphasis, never mathematical notation. Formal notation always lives in math mode like n , O ( n k ) , ∣ x ∣ .
Before we can say "hard" or "easy", we must pin down what a problem is .
Definition Decision problem
A decision problem is a question whose only allowed answers are YES or NO .
Examples:
"Is 17 a prime number?" → YES .
"Does this map need more than 4 colours?" → NO .
Not allowed as a decision problem: "What is the shortest route?" (that answer is a route , not yes/no). We rephrase it: "Is there a route shorter than 100 km?" → now it's YES/NO.
Figure s01 shows this as a machine with one input slot and exactly two lamps — a green YES lamp and a red NO lamp. Every decision problem is the question "which lamp lights up?"; look at how exactly one lamp ever lights.
Intuition Why restrict to YES/NO?
Restricting to two answers lets us compare problems fairly . A theory of "how hard is any question" is a mess; a theory of "how hard is a yes/no question" is clean, and — surprisingly — everything harder can be built out of yes/no questions. See Decision Problems and Languages .
We say some problems are "harder for big inputs". But big needs a number.
Definition Symbols, encoding, and input size
n
First fix an alphabet : a small finite set of symbols the input is written in. The cleanest choice is the bit alphabet { 0 , 1 } , so everything is encoded as a string of bits . (Ten decimal digits, or ASCII characters, only change lengths by a constant factor, so it doesn't matter which fixed alphabet we pick — Big-O will absorb that factor.)
Then input size n is the number of symbols (bits) in the encoded input . A number with 300 decimal digits needs n ≈ 300 × log 2 10 ≈ 997 bits. A list of 50 cities needs n proportional to 50 (plus the bits to name each city).
We also write ∣ x ∣ for "the size of input x ", so ∣ x ∣ = n .
Intuition Why we measure by size, not by the number itself
A 300-digit number is one number, but writing it takes hundreds of symbols. Difficulty should scale with the length you must read , because an algorithm has to at least look at its input. That encoded length — in bits — is n .
Figure s01 also hints at this: the input arrives written out on tape squares; n = how many squares are filled. (That tape is literally a Turing machine tape.)
Now: "harder" = "takes more steps as n grows". We need a way to describe growth while ignoring petty details. (Recall a step is one basic tape action of our algorithm, defined at the top.)
Definition Step count and Big-O
Let T ( n ) = the worst-case number of steps the algorithm takes on inputs of size n .
T ( n ) = O ( f ( n )) ("big-O of f ") means precisely: ==there exist constants c > 0 and n 0 such that for all n > n 0 , we have T ( n ) ≤ c ⋅ f ( n ) .==
In words: past some starting point n 0 , T ( n ) never exceeds a fixed multiple c of f ( n ) . That's what "for large n , at most a constant times f ( n ) " really means — it's a promise about the tail, not the small cases.
Intuition Why throw away constants?
5 n 2 and 100 n 2 both curve upward the same shape — doubling n roughly quadruples both. Whether your computer is 20× faster changes the constant c , not the shape f ( n ) . Big-O captures the shape, which is what survives faster hardware. Full treatment in Big-O and Time Complexity .
Figure s02 is the heart of the whole topic: it plots a polynomial curve n 2 (teal) against an exponential curve 2 n (orange). Watch how they start close near the left, then the orange curve rockets almost straight up.
Definition Polynomial vs exponential
Polynomial time = O ( n k ) for some fixed constant k (like n , n 2 , n 3 ). Called tractable / efficient .
Exponential time = O ( c n ) for some fixed constant c > 1 (like 2 n , 3 n ). Here the exponent grows with the input — that's the hopeless kind. Note "exponential" is c n (variable in the exponent), NOT n c (variable in the base, which is polynomial).
Worked example Feel the difference
At n = 60 : n 2 = 3600 steps (instant). 2 n ≈ 1.15 × 1 0 18 steps — longer than the age of the universe on any real machine. Same n , opposite fates. This gulf is why "polynomial" is the dividing line.
P
P is the collection (a "class") of all decision problems that ==some algorithm can solve — produce the correct YES/NO — in worst-case polynomial time== O ( n k ) for some fixed k ≥ 1 .
The letter P = P olynomial.
Intuition Why "faster than any
n k " is fine, and k is fixed
Binary search on a sorted list runs in O ( log n ) steps. Is that "polynomial"? Yes — and comfortably so: for any fixed k > 0 , log n grows slower than n k , so log n = O ( n k ) . The power k in "O ( n k ) " is always a fixed constant (we usually take k ≥ 1 integer); it never depends on n . Anything at or below some fixed n k counts as in P .
Picture a box labelled P . Inside it sit problems like "is x in this sorted list?" (solvable by binary search, O ( log n ) , which is below any n k ). We draw that box explicitly in figure s04 .
Intuition What "class" means
A class is just a set of problems grouped by a rule . P 's rule is "there's a fast solver." Grouping problems this way lets us make one statement about all of them at once — that's the whole game.
Here is the subtle idea the whole topic hinges on: checking an answer vs finding it.
Definition Certificate (witness)
A certificate is a short hint that helps you confirm a YES answer.
Sudoku: the hint is the fully filled grid. Route problem: the hint is the actual route.
"Short" means its length ∣ c ∣ is bounded by a polynomial in ∣ x ∣ (say ∣ c ∣ ≤ ∣ x ∣ m for some fixed m ) — you can't cheat by hiding a giant answer in the hint.
V ( x , c )
A verifier is a fast checking algorithm. Feed it the input x and a certificate c ; it says YES or NO.
V ( x , c ) = YES or NO, computed in time polynomial in ∣ x ∣.
Two size conditions travel together and both matter:
the certificate is short: ∣ c ∣ ≤ ∣ x ∣ m (polynomial in ∣ x ∣ );
the check is fast: V halts within O ( ∣ x ∣ k ) steps for some fixed k .
Because ∣ c ∣ is itself polynomial in ∣ x ∣ , "polynomial in ∣ x ∣ " and "polynomial in ∣ x ∣ + ∣ c ∣ " mean the same thing here — so it is standard to state the running-time bound in terms of ∣ x ∣ alone. Read V ( x , c ) as "V looks at problem-input x together with hint c ."
Figure s03 draws the verifier as a bouncer at a door: x (teal arrow) is "the club rules", c (plum arrow) is "your ID". The bouncer glances (fast) and admits or rejects. A good hint gets you in; no fake hint gets a non-member in.
N P
N P is the class of decision problems for which ==a polynomial-time verifier V exists== such that:
if the true answer is YES , then some certificate c (with ∣ c ∣ polynomial in ∣ x ∣ ) makes V ( x , c ) = YES ;
if the true answer is NO , then no certificate makes V say YES.
N P = N ondeterministic P olynomial. NOT "Non-Polynomial." It's about fast checking , not slowness.
Common mistake "NP means not-polynomial / unsolvable fast."
Why it feels right: "N-P" reads like "non-polynomial", and these problems seem slow.
The fix: NP = verifiable in poly time. Every easy (P ) problem is also in N P — you'll see exactly why in the next section.
Now the notation that states the actual question.
⊆ (subset)
A ⊆ B means ==every member of A is also a member of B == ("A sits inside B "). Picture one blob drawn inside a bigger blob.
Figure s04 shows the P blob nestled inside the N P blob. The million-dollar mystery is whether those two blobs are actually the same blob .
= and = ?
P = N P means the two classes contain exactly the same problems (the blobs coincide).
The little question mark, P = ? N P , means we do not know whether they are equal — it's an open question , not a claim.
Intuition The statement in one breath
We already know P ⊆ N P . The open half is whether N P ⊆ P too. If yes, P = N P (every check-easy problem is solve-easy). If no, P = N P (some problems are forever check-easy but solve-hard).
Definition Reduction (informal)
To reduce problem A to problem B means: ==use a fast translator algorithm that rewrites any question of type A into a question of type B , so that the two always have the same YES/NO answer.== Then a solver for B also answers A : translate, solve B , report its answer.
Why must the translator itself run in polynomial time? Because the whole point is to transfer efficiency . If solving B is fast but the translation step were slow (say exponential), the combined "translate-then-solve" recipe for A would be slow too — you'd have proven nothing about A 's tractability. Keeping the translator polynomial guarantees: fast B solver ⇒ fast A solver.
Why must YES/NO be preserved exactly? If the translation could turn a YES-instance of A into a NO-instance of B (or vice-versa), then B 's answer would be the wrong answer for A . Answer-preservation is what lets us trust B 's verdict as A 's verdict. Detail in NP-Completeness and Reductions .
Definition NP-complete (preview)
An NP-complete problem is one in N P that ==every other N P problem reduces to== — the hardest problems inside N P . SAT was the first, via the Cook–Levin Theorem . Solve one of these in poly time and P = N P .
Algorithm on a Turing machine
Decision problem YES or NO
Step count and Big-O worst case
Polynomial vs Exponential
Cover the right side and answer each before moving to the parent note.
An "algorithm" is a finite, fixed recipe of unambiguous steps (here, actions of a Turing machine on a tape) turning input into output.
A "step" that we count is one basic tape action of the algorithm — read a square, write a square, or move left/right.
A "decision problem" is a question with only YES or NO as the answer.
The symbol n (also ∣ x ∣ ) stands for the input size — the number of symbols (bits) in the encoded input.
Why the choice of alphabet (bits vs digits) doesn't matter different fixed alphabets change lengths only by a constant factor, which Big-O absorbs.
All our time bounds are measured in the worst case — the most steps over all inputs of size n .
T ( n ) = O ( f ( n )) means preciselythere exist constants c > 0 and n 0 such that T ( n ) ≤ c ⋅ f ( n ) for all n > n 0 .
Polynomial time means O ( n k ) for a fixed constant k — variable in the base.
Exponential time means O ( c n ) for a fixed constant c > 1 — variable in the exponent.
The class P is all decision problems a deterministic algorithm can solve in worst-case polynomial time.
Why O ( log n ) counts as being in P log n = O ( n k ) for any fixed k > 0 , so it is below polynomial.
A certificate (witness) is a short hint whose length ∣ c ∣ is polynomial in ∣ x ∣ , used to confirm a YES answer.
A verifier V ( x , c ) does checks in time polynomial in ∣ x ∣ whether x is a YES-instance, using hint c .
The class N P is problems whose YES-answers can be verified fast given a poly-length certificate.
"NP" stands for Nondeterministic Polynomial — verifiable fast, NOT "non-polynomial".
A ⊆ B meansevery element of A is also in B (A sits inside B).
Why P ⊆ N P a fast solver acts as a verifier that ignores the hint and just solves it.
P = ? N P asksis every check-easy problem also solve-easy? (open — unknown).
A reduction from A to B must be poly-time because otherwise a slow translation would ruin the efficiency transfer — fast B would not give fast A.
A reduction must preserve YES/NO because else B's answer would be the wrong answer for A; preservation makes B's verdict trustworthy as A's.
NP-complete means in N P and every N P problem reduces to it — the hardest problems in N P .