← back to algorithms

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.

SAT Cook-Levin 1971 ≤p 3-SAT ≤p CLIQUE VERTEX COVER Polynomial reductions: solving any one solves them all

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.

Scheme

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.

Scheme

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