Complexity and approximation · 47 / 53
Approximation guarantees, heuristics and FPT
Understand → trace → implement → justify
2 min reading · allow extra time for practiceFor minimisation, α-approximation guarantees ALG≤α·OPT on admissible instances. “99% correct” is not a general definition. Maximisation uses a different ratio direction. Heuristics may perform well without a proven bound. A PTAS is polynomial in n for each fixed ε; an FPTAS is also polynomial in 1/ε.
Taking both endpoints of a maximal matching gives a 2-approximation for vertex cover: an optimum must cover each disjoint matching edge. Metric TSP relies on triangle inequality for shortcutting; its guarantees do not transfer to unrestricted TSP. Greedy set cover has a logarithmic bound, not universal optimality.
FPT separates a small parameter k from n: f(k)·n^c differs from n^k. Branching on an uncovered edge gives a vertex-cover search with O(2^k·poly(n)) time. Kernelisation reduces to an equivalent smaller instance. State the guarantee and its assumptions together.
A worked trace
Select a matching edge, add both endpoints and remove incident edges. The cover need not be minimum.
Cost and assumptions
This repeated-filter model may cost O(E²); suitable adjacency implementation takes O(V+E). The approximation ratio concerns solution quality.
Executable example
Run with Python 3. Assertions check a small example; they do not constitute a general correctness proof. Some advanced examples are explicitly small models or reference oracles, not full production implementations.
def cover_approx(edges):
remaining=list(edges); chosen=set()
while remaining:
u,v=remaining[0]; chosen.update((u,v))
remaining=[(a,b) for a,b in remaining if a not in (u,v) and b not in (u,v)]
return chosen
edges=[(0,1),(1,2),(2,3)]
c=cover_approx(edges)
assert all(u in c or v in c for u,v in edges)TEST YOUR UNDERSTANDING
Your turn
A random greedy result looks good; does it have an approximation guarantee?
Reveal the reasoning
One example is not a proof; a bound and assumptions covering admissible instances are needed.
Take it further
- Write down the input contract and the invariant before changing the example.
- Add empty, boundary, duplicate and adversarial cases where they are relevant. Compare with a simple oracle.
- Derive the cost under the stated model; measure several input sizes and explain discrepancies.
Primary reading & lecture notes
Original explanations in this course; these references provide proofs and further reading. Source links may cover the broader module.
MIT 6.046J · Design and Analysis ↗Jeff Erickson · Algorithms ↗