NP-Completeness and Computational Intractability
Complexity theory asks not only how fast a particular algorithm runs, but also how difficult a problem is in principle. NP-completeness helps identify problems for which a polynomial-time exact algorithm is not currently known.
Decision Problems
A decision problem has a yes/no answer.
Example: “Does this graph contain a Hamiltonian cycle?”
Complexity classes such as P and NP are conventionally defined using decision problems.
Class P
P contains decision problems solvable in polynomial time by a deterministic algorithm.
Examples include graph connectivity and shortest-path decision variants under standard assumptions.
Class NP
NP contains decision problems whose YES instances have certificates verifiable in polynomial time.
Equivalently, NP is the class solvable in polynomial time by a nondeterministic Turing machine.
P ⊆ NP is known; whether P = NP remains open.
NP-Hard
A problem is NP-hard if every problem in NP can be polynomial-time reduced to it.
An NP-hard problem does not have to be a decision problem and does not even have to belong to NP.
NP-Complete
A decision problem is NP-complete when:
- It is in NP.
- It is NP-hard.
Therefore NP-complete problems are the hardest problems inside NP under polynomial-time reductions.
Polynomial-Time Reduction
To show A is no harder than B, transform instances of A into instances of B in polynomial time.
If A is already NP-hard and A ≤p B, then B is NP-hard.
How to Prove NP-Completeness
- Show the new decision problem is in NP.
- Choose a known NP-complete problem A.
- Construct a polynomial-time reduction A ≤p B.
- Prove YES instances map to YES and NO instances map to NO.
Direction matters: reduce the known hard problem to the new problem.
Canonical Examples
| Problem | Classification |
|---|---|
| SAT / 3-SAT | NP-complete decision problems |
| Hamiltonian Cycle | NP-complete |
| Vertex Cover (decision) | NP-complete |
| Subset Sum (decision) | NP-complete |
| TSP decision version | NP-complete |
| Minimum TSP tour | NP-hard optimization problem |
Cook-Levin Theorem
The Cook-Levin theorem established that Boolean satisfiability (SAT) is NP-complete.
Once the first NP-complete problem was known, reductions made it possible to prove many other problems NP-complete.
What P = NP Would Mean
If any NP-complete problem has a polynomial-time algorithm, then every problem in NP has a polynomial-time algorithm.
This does not mean all such algorithms would automatically be practical; polynomial degree and constants still matter.
What We Do in Practice
- Exploit small input sizes
- Use exact exponential algorithms when feasible
- Apply dynamic programming or branch-and-bound
- Use approximation algorithms with guarantees
- Use heuristics when guarantees are unnecessary
- Restrict the problem to tractable special cases
Why This Belongs Before Approximation
Approximation algorithms are motivated largely by NP-hard optimization problems. Once exact polynomial-time solutions appear unlikely, we ask whether a near-optimal solution can be found efficiently with a provable guarantee.
Classification Check
Select a statement and test your understanding.
Relationship Summary
P is contained in NP. NP-complete is the intersection of NP and NP-hard. NP-hard can also contain problems outside NP.