Approximation Algorithms
Approximation algorithms address optimization problems where exact polynomial-time algorithms are unlikely, usually because the problem is NP-hard. Instead of insisting on optimality, they guarantee a solution within a provable factor of optimal. The goal is not "good in experiments"; it is a worst-case mathematical promise connecting algorithm value to optimum [3], [6].
The field combines greedy choices, relaxations, rounding, primal-dual methods, local search, randomized rounding, and hardness theory. This page covers vertex cover, metric TSP, set cover, knapsack FPTAS, Max-3SAT, Steiner tree, k-center, and the PCP theorem as context for why some approximation ratios are difficult or impossible to improve [6], [12].

Figure: A traveling-salesman tour illustrates why exact optimization can be hard even when the objective is easy to state. Image: Wikimedia Commons, public domain or CC-BY-SA via Wikimedia Commons.
Definitions
For a minimization problem, an algorithm has approximation ratio if for every instance ,
Equivalently,
For maximization, the ratio is often written , or as a performance fraction .
An absolute approximation bounds by a constant or additive term. A relative approximation gives a multiplicative ratio. A PTAS gives a -approximation for every fixed in polynomial time, though the exponent may depend badly on . An FPTAS is polynomial in both input size and .
A relaxation enlarges the feasible region so the optimum becomes easier to compute. Linear-programming relaxation lets integer variables become fractional. Rounding maps the relaxed solution back to a feasible integral solution while controlling cost.
Every approximation proof needs a lower bound for minimization or an upper bound for maximization. Sometimes the bound is obvious, such as for metric TSP after deleting one edge from an optimal tour. Sometimes it is a relaxation, such as a fractional LP optimum. Sometimes it is a packing argument, such as the matching lower bound for vertex cover. The algorithm is only half the story; the comparison certificate is what turns a heuristic into an approximation algorithm.
Key results
Vertex cover asks for a minimum set of vertices touching every edge. A simple 2-approximation repeatedly chooses an uncovered edge , adds both endpoints, and deletes all covered edges. The chosen edges form a matching, so any vertex cover must include at least one endpoint from each chosen edge. If the algorithm chooses edges, it returns vertices while optimum is at least . LP relaxation gives another 2-approximation: solve the fractional cover LP and choose every vertex with [6].
Metric TSP assumes distances satisfy the triangle inequality. The MST-doubling algorithm builds a minimum spanning tree, doubles every edge to make all degrees even, takes an Euler tour, and shortcuts repeated vertices. The doubled tree has cost , and shortcutting cannot increase length in a metric. Christofides improves this to by adding a minimum-weight perfect matching on odd-degree MST vertices before shortcutting [7].
Set cover has universe and subsets . Greedy repeatedly chooses the set covering the most uncovered elements. A charging argument gives an approximation, where [8]. LP rounding gives related logarithmic guarantees. Unlike vertex cover, a constant-factor approximation for general set cover would contradict standard hardness assumptions.
Knapsack has an FPTAS despite being NP-hard in its 0/1 form. The pseudo-polynomial DP by total value runs in , where is the sum of values. Scaling values down by a factor depending on and reduces the value range while losing only a controlled fraction of optimum. A common bound is states for a maximization approximation [6].
Max-3SAT asks for an assignment satisfying as many 3-literal clauses as possible. A uniformly random assignment satisfies any clause with probability , since only one of the eight truth assignments to three literals fails. Therefore the expected number of satisfied clauses is , and conditional expectation derandomizes this into a deterministic -approximation.
Steiner tree asks for the cheapest tree connecting required terminals, possibly using extra nonterminal vertices. Metric closure and MST-style approaches give constant approximations. The -center problem asks for centers minimizing maximum client distance. The greedy farthest-first traversal gives a 2-approximation in metric spaces: after choosing the first center, repeatedly choose the point farthest from existing centers.
The PCP theorem states, roughly, that every NP statement has proofs checkable with constant randomness and a constant number of queried bits, with a gap between yes and no instances [12]. Its algorithmic consequence is hardness of approximation: for many problems, improving a ratio beyond a threshold is NP-hard. This does not make approximation pessimistic; it tells us which guarantees are meaningful targets.
Approximation schemes are especially sensitive to input encoding. A pseudo-polynomial algorithm may look polynomial in a numeric value like capacity , but the input length contains only bits for that number. An FPTAS must be polynomial in and the encoded input size, which is why scaling values rather than capacities is the standard route for knapsack when values are the DP dimension.
Visual
| Problem | Algorithm | Guarantee | Main proof idea |
|---|---|---|---|
| Vertex cover | maximal matching endpoints | 2-approx | matching lower bound |
| Vertex cover | LP rounding at | 2-approx | fractional lower bound |
| Metric TSP | MST doubling | 2-approx | tree lower bound plus shortcutting |
| Metric TSP | Christofides | 1.5-approx | matching odd-degree vertices |
| Set cover | greedy | -approx | charging uncovered elements |
| 0/1 knapsack | value scaling DP | FPTAS | bounded rounding loss |
| Max-3SAT | random assignment | expected | clause satisfaction probability |
| k-center | farthest-first | 2-approx | packing lower bound |
Worked example 1: MST-doubling TSP on four metric nodes
Problem. Four nodes have metric distances:
| edge | distance |
|---|---|
| A-B | 1 |
| B-C | 2 |
| C-D | 1 |
| A-D | 2 |
| A-C | 2 |
| B-D | 2 |
Use MST doubling to produce a TSP tour.
Method.
- Build an MST. Choose edges A-B(1), C-D(1), and B-C(2). MST cost is .
- Double MST edges. The doubled multigraph cost is and every vertex has even degree.
- One Euler tour is
- Shortcut repeated vertices using the triangle inequality. Visit first occurrences:
- Tour cost is , , , , total .
Checked answer. The algorithm returns a tour of cost . Since any TSP tour contains a spanning connected structure, , so the 2-approx bound allows cost up to . The produced tour is within that guarantee.
Worked example 2: greedy set cover analysis
Problem. Universe and sets
Run greedy set cover.
Method.
- Initially all 6 elements are uncovered. and each cover 3. Break ties by choosing .
- Covered: . Uncovered: .
- Marginal gains now: covers , covers , covers . Choose .
- Covered: all elements. Greedy returns .
Checked answer. The greedy cover has size 2, and it is optimal because no single set covers all six elements. The general analysis would charge the first three elements at price each and the last three at price each in this instance, totaling 2. On worse instances, the same charging style yields the harmonic bound .
Code
def vertex_cover_2approx(edges):
uncovered = {tuple(edge) for edge in edges}
cover = set()
while uncovered:
u, v = next(iter(uncovered))
cover.add(u)
cover.add(v)
uncovered = {e for e in uncovered if u not in e and v not in e}
return cover
def set_cover_greedy(universe, sets):
uncovered = set(universe)
chosen = []
while uncovered:
name, subset = max(sets.items(), key=lambda item: len(uncovered & set(item[1])))
gain = uncovered & set(subset)
if not gain:
raise ValueError("universe cannot be covered")
chosen.append(name)
uncovered -= gain
return chosen
def tsp_mst_doubling(nodes, dist):
parent = {v: v for v in nodes}
def find(x):
while parent[x] != x:
parent[x] = parent[parent[x]]
x = parent[x]
return x
def union(a, b):
ra, rb = find(a), find(b)
if ra == rb:
return False
parent[rb] = ra
return True
edges = sorted((dist[a, b], a, b) for i, a in enumerate(nodes) for b in nodes[i + 1:])
tree = {v: [] for v in nodes}
for w, a, b in edges:
if union(a, b):
tree[a].append(b)
tree[b].append(a)
tour = []
seen = set()
def preorder(u, p=None):
seen.add(u)
tour.append(u)
for v in tree[u]:
if v != p:
preorder(v, u)
preorder(nodes[0])
tour.append(nodes[0])
def distance(a, b):
return dist.get((a, b), dist.get((b, a)))
cost = sum(distance(a, b) for a, b in zip(tour, tour[1:]))
return tour, cost
Common pitfalls
- Reporting empirical solution quality as an approximation ratio without a proof.
- Mixing minimization and maximization ratio conventions.
- Forgetting that metric TSP approximations rely on the triangle inequality.
- Applying MST doubling to nonmetric TSP and expecting the same guarantee.
- Treating Christofides as a general TSP approximation rather than metric TSP.
- Using greedy set cover and claiming a constant-factor guarantee.
- Rounding every positive LP variable up without bounding the cost increase.
- Calling a pseudo-polynomial knapsack DP polynomial in the input length.
- Scaling knapsack values too coarsely and losing more than the allowed .
- Assuming a randomized expected guarantee automatically holds for every run.
- Ignoring hardness results when promising better ratios for standard NP-hard problems.
- Confusing approximation algorithms with heuristics; heuristics may work well but lack worst-case guarantees.
Connections
- Greedy Algorithms for set cover, interval ideas, and local-choice proofs.
- Dynamic Programming for knapsack pseudo-polynomial DP and FPTAS construction.
- Graph Algorithms for MSTs, matchings, cuts, TSP, and k-center metrics.
- Network Flow and Matching for LP relaxations, vertex cover in bipartite graphs, and matching lower bounds.
- Randomized Algorithms for random assignment, randomized rounding, and probability amplification.
- Theory of Computation for NP-hardness and PCP-based hardness of approximation.
- Discrete Math for graphs, set systems, and linear-programming intuition.
References
[1] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algorithms, 4th ed. MIT Press, 2022.
[2] R. Sedgewick and K. Wayne, Algorithms, 4th ed. Addison-Wesley, 2011.
[3] J. Kleinberg and E. Tardos, Algorithm Design. Pearson, 2005.
[4] S. S. Skiena, The Algorithm Design Manual, 3rd ed. Springer, 2020.
[5] R. Motwani and P. Raghavan, Randomized Algorithms. Cambridge University Press, 1995.
[6] V. V. Vazirani, Approximation Algorithms. Springer, 2003.
[7] N. Christofides, "Worst-case analysis of a new heuristic for the travelling salesman problem," Graduate School of Industrial Administration, Carnegie Mellon University, Report 388, 1976.
[8] L. Lovasz, "On the ratio of optimal integral and fractional covers," Discrete Mathematics, vol. 13, no. 4, pp. 383-390, 1975.
[9] D. S. Johnson, "Approximation algorithms for combinatorial problems," Journal of Computer and System Sciences, vol. 9, no. 3, pp. 256-278, 1974.
[10] D. S. Hochbaum and D. B. Shmoys, "A best possible heuristic for the k-center problem," Mathematics of Operations Research, vol. 10, no. 2, pp. 180-184, 1985.
[11] M. X. Goemans and D. P. Williamson, "Improved approximation algorithms for maximum cut and satisfiability problems using semidefinite programming," Journal of the ACM, vol. 42, no. 6, pp. 1115-1145, 1995.
[12] S. Arora, C. Lund, R. Motwani, M. Sudan, and M. Szegedy, "Proof verification and the hardness of approximation problems," Journal of the ACM, vol. 45, no. 3, pp. 501-555, 1998.
[13] P. Raghavan and C. D. Thompson, "Randomized rounding: A technique for provably good algorithms and algorithmic proofs," Combinatorica, vol. 7, pp. 365-374, 1987.
[14] M. H. Hajiaghayi and K. Jain, "The prize-collecting generalized Steiner tree problem via a new approach of primal-dual schema," SODA, pp. 631-640, 2006.