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.

Important distinction: NP-completeness is defined for decision problems. Optimization problems such as finding the shortest TSP tour are usually described as NP-hard, while their decision versions can be NP-complete.

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.

O(n), O(n log n), O(n²), O(n^k) → polynomial time

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:

  1. It is in NP.
  2. 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.

A ≤p B

If A is already NP-hard and A ≤p B, then B is NP-hard.

How to Prove NP-Completeness

  1. Show the new decision problem is in NP.
  2. Choose a known NP-complete problem A.
  3. Construct a polynomial-time reduction A ≤p B.
  4. 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

ProblemClassification
SAT / 3-SATNP-complete decision problems
Hamiltonian CycleNP-complete
Vertex Cover (decision)NP-complete
Subset Sum (decision)NP-complete
TSP decision versionNP-complete
Minimum TSP tourNP-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.

Choose an answer.

Relationship Summary

P
NP
NP-Complete
NP-Hard

P is contained in NP. NP-complete is the intersection of NP and NP-hard. NP-hard can also contain problems outside NP.