Approximation Algorithms
When a problem is -hard we can still ask for a solution provably close to optimal. This lesson makes the approximation ratio precise, separates absolute from relative guarantees, and proves the ratios of four classic algorithms: greedy set cover (), the MST-doubling -approximation for metric TSP, load balancing, and the knapsack FPTAS.
╌╌╌╌
The previous lesson, Coping with NP-Hardness, surveyed four honest responses to a problem we cannot solve exactly and quickly: approximate, use heuristics, pay for a smart exponential search, or exploit special structure. It worked the first response through a single example, the -approximation for vertex cover. This lesson develops that response in detail. We define the approximation ratio with care, separate two flavors of guarantee, and then prove ratios for a sequence of canonical algorithms, each illustrating a different proof technique. We finish by classifying which problems can be approximated arbitrarily well, and which cannot be approximated at all.
The recurring move, established last time, is worth restating because every proof below is a variation on it: we bound our output not against the optimum , which we cannot compute, but against a surrogate quantity, a lower bound for a minimization (or an upper bound for a maximization) that we can reason about. Most of approximation analysis is finding the right surrogate.
What approximate
means precisely
Fix an optimization problem. On an instance , let be the cost
of an optimal solution and the cost of the solution our algorithm
returns. There are two distinct ways to say is close to optimal,
and
conflating them causes endless confusion.
Absolute guarantees are rare: most -hard problems scale, so an additive error that holds on small instances cannot hold on large ones. (If you could always come within of the optimal graph coloring, you could take disjoint copies of an instance and divide out the additive slack to solve it exactly.) So the relative ratio is the standard guarantee, and we pin it down exactly.
Two conventions are in use. Some authors quote the maximization ratio as a
fraction (a -approximation
returns at least half of
optimal); others keep throughout. They say the same thing; we will use
for minimization and the fraction for maximization, and
state which we mean each time.
A ratio may be a constant ( for vertex cover), may grow with the input ( for set cover, as we are about to prove), or may be tunable to any value above at the cost of running time (an approximation scheme). The last section organizes these into a hierarchy.
Greedy set cover: a logarithmic ratio
Our first proof gives a ratio that is not constant — it grows like the logarithm of the input — and it introduces the charging argument, where we account for the algorithm's cost by distributing it onto the elements it serves.
Set cover is -hard, and it is the abstract form of many resource-selection problems: pick the fewest cell towers covering every neighborhood, the fewest tests catching every fault, the fewest committees spanning every skill. The natural greedy rule is simple: repeatedly take the set that covers the most still-uncovered elements.1
- 1
- 2elements still uncovered
- 3while do
- 4pick maximizingmost new coverage
- 5
- 6remove newly covered elements
- 7return
Each iteration covers at least one new element, so the loop runs at most times; finding the best set is polynomial, so the whole algorithm is. The figure shows the first greedy choice: among the available sets, the one covering the largest part of the uncovered universe wins.
Greedy can use more sets than necessary, and the worst case is genuinely logarithmic. The classic bad instance is a universe of elements that the optimum covers with two sets, but greedy peels off in steps, each grabbing barely more than half of what remains. The precise bound uses the harmonic number .
The logarithmic factor is not an artifact of the analysis: greedy is essentially optimal here. A deep result shows that, unless , no polynomial-time algorithm approximates set cover within .2 Greedy is the best we can hope for, up to lower-order terms.
Metric TSP: the MST-doubling 2-approximation
The traveling-salesman problem asks for a minimum-cost cycle visiting every vertex once. In full generality it admits no constant-factor approximation (established at the end of this lesson). But almost every TSP that arises from geography or physical distance satisfies the triangle inequality, — going direct is never longer than detouring through a third point. This metric case admits a -approximation built on the minimum spanning tree.3
The coping lesson sketched this construction; here we develop it in full and prove the ratio. The whole idea fits in one line: an MST is a cheap connected backbone, and a tour is just a connected backbone with the extra demand of being a single cycle, so the tour cannot cost much more than the tree.
- 1minimum spanning tree ofe.g. Prim or Kruskal
- 2pick any vertex as root
- 3vertices in the order first visited by a preorder walk of from
- 4return the cycle that visits the vertices in the order , then closes back to
The algorithm never literally doubles edges; the preorder walk is the clean way to
realize the double then shortcut
intuition. Doubling each tree edge makes every
degree even, so an Euler tour exists that traverses every (doubled) edge once
and has cost exactly . Walking that Euler tour and skipping vertices
already seen yields precisely the preorder sequence . The figure shows both
halves: the MST backbone, then the shortcut Hamiltonian cycle.
Both inequalities are tight in isolation, so is the honest guarantee for this particular algorithm. It is not the best ratio known: Christofides' algorithm replaces the wasteful doubling with a cleverer parity fix. Instead of duplicating every tree edge, it adds a minimum-weight perfect matching on just the odd-degree vertices of — the only vertices whose degree blocks an Euler tour. That matching costs at most , and the same shortcutting argument then yields a tour of cost at most .4 For decades the resulting was the best constant known for metric TSP.
Load balancing: a second 2-approximation, by averaging
To show a different surrogate at work, consider makespan scheduling: assign jobs with processing times to identical machines so as to minimize the makespan, the finishing time of the busiest machine. Deciding the optimum is -hard. The list-scheduling greedy assigns each job, in turn, to whichever machine is currently least loaded.
- 1current load of each machine
- 2for to do
- 3least-loaded machine
- 4assign job to machine
- 5
- 6return the assignment
This greedy needs only two facts that lower-bound any schedule, including the optimum.
The same two surrogates, sharpened, show that sorting jobs longest-first before list-scheduling improves the ratio to — a reminder that the order in which a greedy commits often matters more than the greedy rule itself.5
A knapsack FPTAS: approximation you can dial in
The algorithms so far hit a fixed ratio. For some problems, any accuracy is achievable: a - (or -) approximation, paying in running time. The 0/1 knapsack problem is the textbook case, and its scheme is fully polynomial — polynomial in both the input size and .6
Recall knapsack: items with weights and profits , a capacity ; choose a subset of weight at most maximizing total profit. There is an exact dynamic program indexed by profit running in time , where . That is fast when profits are small but blows up when they are large — it is pseudo-polynomial, polynomial in the value , not in its bit-length.
The FPTAS exploits this dependence. Large profits are what inflate the profit-indexed table, so we scale them down and round, shrinking the table to a controllable size while distorting the answer only slightly.
- 1largest single profit
- 2scaling unit
- 3for to do
- 4round profits down
- 5solve knapsack exactly on profits by the profit-indexed DP
- 6return that chosen subset (valued by the true )
Rounding the profits to multiples of caps the scaled profits at , so the profit-indexed DP now runs in time — polynomial in and in . It remains to bound the lost profit.
The two error sources are now visible. Rounding down loses at most per chosen item, hence at most in total; the scaling choice makes that total exactly . Smaller means finer , a larger table, and a slower-but-sharper answer — the running time grows as , never as an exponential.
The hierarchy, and where approximation runs out
Naming the qualitative differences we have seen organizes the whole subject.
An FPTAS is the strongest guarantee: accuracy becomes a parameter. The guarantees form a hierarchy, each level strictly stronger than the one below.
The bottom level is real: some problems admit no constant-factor approximation at all, and the proofs are themselves reductions. The canonical example is the general traveling-salesman problem, with no triangle inequality.7
The gap-creating trick — pricing non-edges so high that any decent approximation is forced to avoid them — is the prototype for hardness-of-approximation. Its modern descendant, the PCP theorem, constructs such gaps for a vast range of problems, settling the exact approximation threshold of MAX-3SAT, set cover, and many others, and explaining why the ratios proved above so often turn out to be the best possible.
Tight thresholds and the approximability frontier
The gap reduction above shows some ratio is unachievable; the modern result is that the guarantees this lesson proved are often exactly optimal — the algorithm and the hardness bound meet at the same constant. Three landmark results draw that frontier:
- Set cover is , tight. The greedy ratio from earlier in this lesson cannot be improved: Feige (1998) proved that a -approximation for set cover would imply , essentially .8 No polynomial algorithm for set cover can do better than greedy.
- MAX-3SAT is , tight. A trivial random assignment satisfies of the clauses of a MAX-3SAT instance in expectation. Håstad (2001) proved via the PCP machinery that beating is -hard — so the simplest possible algorithm is already optimal.9
- Dinur's combinatorial PCP. The original PCP theorem's proof was famously intricate; Dinur (2007) gave a different gap-amplification proof that builds the required hardness gap incrementally, making inapproximability accessible without the heavy algebra.10
One frontier remains genuinely open. The Unique Games Conjecture (Khot, 2002) posits the hardness of a specific constraint problem; if true, it would fix the exact approximation threshold of a wide range of problems at once, including vertex cover (making our factor- optimal) and MAX-CUT.11 Whether UGC holds is one of the central open questions of complexity theory today.
Takeaways
- An approximation algorithm runs in polynomial time with a provable bound on how far from optimal it can land. The relative ratio (cost for minimization, for maximization) is the standard guarantee; absolute additive guarantees are rare because hard problems scale.
- Every proof bounds the output against a surrogate for the unknown optimum: a charging argument for greedy set cover (, and no polynomial algorithm beats ), the MST for metric TSP ( gives a -approximation; Christofides sharpens it to ), and two universal lower bounds (average load, biggest job) for list-scheduling makespan (-approximation).
- A PTAS achieves any ratio in time polynomial in ; an FPTAS is also polynomial in . The knapsack FPTAS scales and rounds profits to shrink the pseudo-polynomial DP, losing at most .
- Some problems are inapproximable: unless , general TSP has no constant-factor approximation, shown by pricing non-edges to create a gap that would otherwise decide Hamiltonicity. Hardness of approximation is proved by reductions, just like -hardness itself.
Footnotes
- CLRS, Ch. 35 — Approximation Algorithms (§35.3): the greedy set-cover heuristic and its approximation bound via the per-element charging argument. ↩
- CLRS, Ch. 35 — Approximation Algorithms: greedy set cover is essentially optimal; under no polynomial algorithm achieves ratio . ↩
- CLRS, Ch. 35 — Approximation Algorithms (§35.2): the MST-doubling -approximation for metric (triangle-inequality) TSP, with and shortcutting bounded by the triangle inequality. ↩
- Skiena, §11.10 — Approximation Algorithms: Christofides' -approximation for metric TSP, fixing odd-degree parity with a minimum-weight perfect matching instead of doubling the whole tree. ↩
- CLRS, Ch. 35 — Approximation Algorithms (Problem 35-5): list scheduling for makespan is a -approximation; the longest-processing-time rule improves the bound to . ↩
- CLRS, Ch. 35 — Approximation Algorithms (§35.5): the fully polynomial-time approximation scheme for the subset-sum / knapsack problem by trimming and scaling, giving in time polynomial in and . ↩
- Erickson, Ch. 12 — NP-Hardness: gap reductions and inapproximability, including the proof that general TSP admits no constant-factor approximation unless . ↩
- Uriel Feige,
A Threshold of for Approximating Set Cover,
Journal of the ACM 45(4), 1998 — the matching hardness lower bound making greedy optimal for set cover. ↩ - Johan Håstad,
Some Optimal Inapproximability Results,
Journal of the ACM 48(4), 2001 — the tight threshold for MAX-3SAT and other optimal PCP-based inapproximability results. ↩ - Irit Dinur,
The PCP Theorem by Gap Amplification,
Journal of the ACM 54(3), 2007 — a combinatorial gap-amplification proof of the PCP theorem. ↩ - Subhash Khot,
On the Power of Unique 2-Prover 1-Round Games,
STOC 2002 — the Unique Games Conjecture, which if true fixes the optimal approximation ratio for vertex cover, MAX-CUT, and many others. ↩
╌╌ END ╌╌