4.6.29 · D3Theory of Computation

Worked examples — Approximation algorithms — approximation ratio, examples

4,355 words20 min readBack to topic

Before anything, three symbols must be earned — the parent note used and freely, but on this page we define them from zero.


The scenario matrix

Every approximation question you'll meet lives in one of these cells. The worked examples below are each tagged with the cell they cover, so together they fill the whole grid.

# Cell (case class) What makes it special Covered by
C1 Trivial / zero input — empty graph, one job, no edges OPT ; ratio is — a division trap Ex 1
C2 Loose ratio — algorithm far better than its guarantee ; guarantee is not equality Ex 2b (loose); Ex 2 (still tight)
C3 Tight ratio — worst case, equals 2 ratio equals ; proves the bound can't improve Ex 3, Ex 5
C4 Metric geometry — triangle inequality active shortcutting saves cost Ex 4
C5 Non-metric trap — triangle inequality broken bound collapses; algorithm may be arbitrarily bad Ex 6
C6 Two-lower-bound problem — load balancing must combine average + max Ex 7
C7 Real-world word problem — jobs, servers, dressed-up numbers translate words → makespan Ex 8
C8 Exam twist — max vs min convention, PTAS reasoning sign of the ratio flips Ex 9

Two quick reminders of the value-notation before we start (earned, not assumed):

The figure below is the mental image behind every example on this page — keep glancing back at it. The yellow dot is the wall we can compute, the pink dot is the hidden OPT we can't, and the blue dot is where our algorithm lands. The blue arrow ("", the ratio) is the only thing we prove directly; the yellow arrow ("") is free.

Figure — Approximation algorithms — approximation ratio, examples

C1 — The zero / degenerate input


C2 — When the algorithm is much better than its promise

To see a genuinely loose (strictly below 2) we cannot use a graph where every edge shares one vertex — those force ties at 2. We need a graph where OPT exceeds the matching size .


C3 — The tight case (worst possible)

Figure — Approximation algorithms — approximation ratio, examples

The figure contrasts the two extremes referenced in the steps below. Left panel = Graph A of Ex 3 (triangle): the blue vertices are the cover; , ratio (loose). Right panel = Graph B of Ex 3 (three disjoint pink edges): the algorithm picks all three (blue "pick" endpoints), doubling a matching that OPT covers with one vertex per edge; ratio (tight). Read the two panels as "best case vs adversary's best weapon".


C4 — Metric TSP, triangle inequality doing real work

Figure — Approximation algorithms — approximation ratio, examples

In this figure (matching Ex 4) the yellow edges are the MST (three sides of the unit square, cost ), the pink dotted edge is the unused diagonal ( — too costly), and the blue dashed edge is the shortcut that closes the tour in step 3. Watch how shortcutting turns the doubled walk into the clean 4-edge perimeter.


C5 — The non-metric trap


C6 & C7 — Load balancing: two lower bounds, and a real job

Figure — Approximation algorithms — approximation ratio, examples

The bar chart shows the greedy result of Ex 7: stacked jobs on two machines, the blue dashed line marking the achieved makespan (ALG ) and the yellow dotted line marking OPT (which equals the average-load lower bound here). The gap between the two lines is the approximation slack.


C8 — The exam twist: maximization convention



Connections

  • Hinglish parent · NP-completeness
  • Vertex Cover · Maximum Matching — tight/loose cells C2, C3.
  • Minimum Spanning Tree · Triangle Inequality — metric & non-metric cells C4, C5.
  • Greedy Algorithms — load-balancing cells C6, C7.
  • PTAS and FPTAS · Inapproximability / PCP theorem — why non-metric TSP has no constant factor.