computational complexity
Approximation Algorithms
You should know: reductions and np completeness
Overview
When a problem is NP-hard, insisting on the exact optimum is often infeasible at scale — so approximation algorithms trade a small, provable amount of solution quality for a guarantee of polynomial running time. An approximation algorithm comes with an approximation ratio: a proven bound on how far its output can be from the true optimum, in the worst case, over ALL inputs. This turns 'we can't solve this exactly, fast' into a precise, quantitative statement: 'we can always get within a factor of 2 of optimal, fast' (for example). Some NP-hard problems (like vertex cover and metric TSP) admit small constant-factor approximations; others (like general TSP without the triangle inequality) provably admit no bounded-factor approximation at all unless P = NP, and a few (the 'PTAS' problems) can be approximated arbitrarily closely at the cost of increasing runtime.
Intuition
Suppose you can't find the single cheapest way to cover all the edges of a graph with vertices (vertex cover is NP-hard), but you CAN quickly find a cover that's never worse than twice the cheapest possible. That's a huge practical win: instead of an algorithm that might take exponential time to find the perfect answer, you get an instant, provably-bounded-quality answer. The key discipline of approximation algorithms is proving the ratio holds for every possible input, not just typical ones — you need a mathematical argument (usually comparing your algorithm's output to some easy-to-compute lower bound on the true optimum, like a matching) that the guarantee never breaks, no matter how adversarial the input.
Formal Definition
For a minimization problem, an algorithm A is a ρ-approximation algorithm if, for every input instance I, it runs in polynomial time and its output ALG(I) is bounded relative to the true optimum OPT(I):
Notation
| Notation | Meaning |
|---|---|
| The value of the true optimal solution to instance I | |
| The value of the solution produced by the approximation algorithm on I | |
| The approximation ratio — the algorithm's worst-case guaranteed factor from optimal | |
| Polynomial-time approximation scheme: a family of algorithms achieving any fixed (1+ε) ratio |
Theorems
Applications
Worked Examples
The true minimum vertex cover for this path is {2, 4}: vertex 2 covers edges (1,2) and (2,3); vertex 4 covers edges (3,4) and (4,5). Every edge is covered, so OPT = 2.
The matching {(1,2), (3,4)} is maximal (no edge can be added without sharing an endpoint with an existing matched edge: edge (2,3) shares vertex 2 or 3 with both matched edges). Taking both endpoints of each matched edge gives the cover {1,2,3,4}.
Check the ratio: ALG / OPT = 4 / 2 = 2, matching the algorithm's guaranteed worst-case bound of exactly 2.
Answer: ALG = 4 and OPT = 2, giving a ratio of exactly 2 — consistent with (and tight for) the general 2-approximation guarantee: taking both endpoints of a maximal matching never exceeds twice the true minimum vertex cover.
Practice Problems
Why does taking BOTH endpoints of every edge in a maximal matching (rather than just one, cleverly chosen, endpoint) give a provable approximation guarantee for vertex cover?
A logistics company has a delivery network satisfying the triangle inequality (direct routes are never longer than routes through a third stop) and wants a tour of all 50 delivery points. If Christofides' algorithm returns a tour of length 180, what is the largest possible value of the true optimal tour length, and the smallest?
A ρ-approximation algorithm for a minimization NP-hard problem guarantees that its solution is:
Common Mistakes
Believing an approximation ratio is a statement about average performance on typical inputs.
An approximation ratio is a WORST-CASE guarantee: it must hold for every possible input instance, including adversarially constructed ones, not just 'typical' or 'random' ones. This is what makes it a mathematically provable guarantee rather than an empirical observation.
Assuming every NP-hard optimization problem admits a good (small constant-factor) approximation algorithm.
Some NP-hard problems provably admit NO bounded-ratio polynomial-time approximation at all unless P = NP (e.g. general TSP without the triangle inequality, or maximum clique within any constant factor) — approximability itself varies enormously and must be established or refuted problem by problem.
Quiz
Flashcards
Historical Background
The systematic study of approximation algorithms grew directly out of 1970s NP-completeness theory: once Cook, Levin, and Karp established that huge classes of optimization problems have no known efficient exact algorithms, researchers began asking how CLOSE to optimal a polynomial-time algorithm could provably get. Nicos Christofides's 1976 algorithm for the metric Traveling Salesman Problem, guaranteeing a solution within 1.5x optimal, became a landmark early result. David Johnson's 1974 work formalized approximation ratios for problems like set cover and graph coloring, and the field matured further in the 1990s with the PCP theorem, which supplied the tools to prove HARDNESS of approximation — showing that for some problems, no algorithm can even get close to optimal in polynomial time unless P = NP.
- 1974
David Johnson formalizes worst-case approximation ratios for several NP-hard optimization problems
David S. Johnson
- 1976
Nicos Christofides publishes a 1.5-approximation algorithm for metric TSP
Nicos Christofides
- 1992
The PCP theorem enables proofs of hardness of approximation for many NP-hard problems
Sanjeev Arora, others
Summary
- Approximation algorithms trade a proven, bounded loss in solution quality for guaranteed polynomial running time on NP-hard problems.
- The approximation ratio ρ must hold for every input in the worst case, not merely on average.
- Vertex cover has a simple 2-approximation via maximal matching; metric TSP has Christofides' 1.5-approximation.
- Not every NP-hard problem is approximable to within a constant factor — inapproximability results (often via the PCP theorem) prove some problems resist even approximate polynomial-time solutions unless P = NP.
References
- WebsiteWikipedia — Vertex cover
Mathematics