NP-Completeness
Algorithms · Advanced Placement
NP-Completeness: the big picture
The class P contains decision problems solvable in polynomial time, and NP contains those whose yes-instances have a certificate verifiable in polynomial time; every problem in P is in NP because the solution itself serves as a certificate, and whether the inclusion is strict is the central open question of the subject. A polynomial-time reduction from one problem to another transforms instances of the first into instances of the second preserving the answer, which shows the second is at least as hard; a problem is NP-complete if it is in NP and every problem in NP reduces to it, so a polynomial algorithm for any NP-complete problem would give one for all. Cook and Levin showed that Boolean satisfiability is NP-complete directly from the definition, and every subsequent NP-completeness proof reduces from a problem already known to be complete. The standard catalogue includes 3-satisfiability, clique, vertex cover, independent set, Hamiltonian cycle, travelling salesman, subset sum and graph colouring, and the reductions among them are instructive in their own right. Establishing NP-completeness redirects effort: it means no efficient exact algorithm should be expected in general, so attention turns to approximation, to parameterised algorithms efficient when some parameter is small, to heuristics, or to identifying tractable special cases.
P, NP, Reductions & the Standard Catalogue
P is what you can solve quickly, NP is what you can check quickly, and whether they differ is the central open question. A polynomial reduction from A to B shows B is at least as hard as A, which is how hardness propagates. A problem is NP-complete when it is in NP and everything in NP reduces to it, so one efficient algorithm for any of them would collapse the whole class. Proving a problem NP-complete is therefore not a dead end but a redirection — toward approximation, parameterisation, or tractable special cases.
{{illustration:algos-l19-f1}}
{{illustration:algos-l19-f2}}
Key relations
- Classes and completeness. P subseteq NP ; A ≤ₚ B and B ∈ P ⇒ A ∈ P ; B NP−complete ⇔ B ∈ NP and ∀ A ∈ NP: A ≤ₚ B
Satisfiability, Verification & What Hardness Does Not Mean
Boolean satisfiability was the first problem proved NP-complete, and it remains the central one — partly because modern SAT solvers routinely handle instances with millions of variables. That is the point most often missed: NP-completeness is a statement about worst-case asymptotic behaviour, not about whether real instances are solvable. Industrial SAT solvers verify hardware designs and prove software properties daily, and the instances that defeat them have to be constructed deliberately.
{{illustration:algos-l19-f3}}
{{illustration:algos-l19-f4}}
Key relations
- Satisfiability and brute force. φ = (x₁ vee neg x₂ vee x₃) wedge ⋯ ; |assignments| = 2ⁿ