NP-Completeness
Nievergelt & Hinrichs · Ch. 10 · Algorithms and Data Structures
P = problems solvable in polynomial time. NP = problems whose solutions are verifiable in polynomial time. NP-complete problems are the hardest in NP: if you solve one in polynomial time, you solve them all. Nobody has proved P = NP or P ≠ NP. The question is the central open problem in computer science.
What is a reduction?
Problem A reduces to problem B (written A ≤p B) if you can transform any instance of A into an instance of B in polynomial time. If B is easy, A is easy. Contrapositive: if A is hard, B is hard. This is how hardness spreads.
The NP-complete zoo
SAT (satisfiability), 3-SAT, CLIQUE (is there a complete subgraph of size k?), VERTEX COVER (can you cover all edges with k vertices?), HAMILTONIAN CYCLE, SUBSET SUM, KNAPSACK. All are NP-complete. All reduce to each other in polynomial time. None have known polynomial-time algorithms.
Approximation
When exact solutions are intractable, approximation algorithms guarantee solutions within a factor of optimal. Vertex cover has a 2-approximation. Traveling salesman with triangle inequality has a 1.5-approximation (Christofides). General TSP has no constant-factor approximation unless P = NP.
Neighbors
Cross-references
- 🔢 Discrete Math Ch.3 — logic: SAT is satisfiability of propositional formulas
- 🔀 Theory of Computation Ch.8 — P vs NP is the complexity-theoretic framing of the same question
- 🔐 Cryptography — every hard crypto problem relies on an NP-hard assumption
- ✎ Proofs Ch.3 — NP-completeness proofs use contradiction and reduction