4.6.29Theory of Computation

Approximation algorithms — approximation ratio, examples

2,077 words9 min readdifficulty · medium2 backlinks

WHAT is an approximation ratio?


Example 1 — Vertex Cover (2-approximation)

Algorithm (Maximal Matching based):

  1. CC\leftarrow\varnothing.
  2. While there is an uncovered edge (u,v)(u,v): add both uu and vv to CC, delete all edges touching uu or vv.
  3. Return CC.
Figure — Approximation algorithms — approximation ratio, examples

Example 2 — Metric TSP (2-approximation via MST)

Algorithm (Double-tree):

  1. Build a Minimum Spanning Tree TT.
  2. Do a DFS/Euler walk of TT (each edge twice) → walk cost =2cost(T)=2\cdot\text{cost}(T).
  3. Shortcut repeated cities (skip already-visited) → a valid tour.

Example 3 — Load Balancing (Greedy, 2-approximation)

Assign nn jobs to mm machines, minimize the makespan (max load).




Recall Feynman: explain to a 12-year-old

Imagine packing a backpack the perfect way takes forever. Instead you use a quick rule of thumb. You can't tell exactly how good the perfect packing is — but you can find a floor: "the perfect packing needs at least this much space." Then you show "my quick way uses at most twice that floor." Since the perfect answer is above the floor too, my quick answer is at most twice the perfect one. That promise — without ever knowing the perfect answer — is the approximation ratio.


Connections

  • NP-completenesswhy we approximate at all.
  • Vertex Cover · Maximum Matching — the 2-approx lower bound.
  • Minimum Spanning Tree — bound for Metric TSP.
  • Greedy Algorithms — load balancing.
  • PTAS and FPTAS · Inapproximability / PCP theorem.
  • Triangle Inequality — enables shortcutting.

What is an approximation ratio for a minimization problem?
The worst-case ratio ALG/OPT ≤ ρ (ρ≥1) over all inputs; ρ=1 is exact.
Why can we prove ratios without knowing OPT?
Find a lower bound LB ≤ OPT (matching size, MST cost, average load), prove ALG ≤ ρ·LB, then ALG ≤ ρ·LB ≤ ρ·OPT.
Vertex Cover 2-approx: what is the algorithm?
Repeatedly pick any uncovered edge, add BOTH endpoints to the cover, remove incident edges.
Why is OPT ≥ |M| in the Vertex Cover proof?
The picked edges form a matching; each disjoint edge needs ≥1 distinct cover vertex, so OPT ≥ matching size.
Why is ALG = 2|M| in Vertex Cover?
We add exactly 2 vertices per matched edge.
Metric TSP double-tree: lower bound on OPT?
Removing one edge from an optimal tour gives a spanning tree, so cost(MST) ≤ OPT.
Why does shortcutting not increase tour cost?
Triangle inequality: skipping a city (a→c instead of a→b→c) costs ≤ the detour.
Load balancing greedy ratio and why?
2; because OPT ≥ average load and OPT ≥ max job size, and L ≤ (L−t_j)+t_j ≤ 2·OPT.
Difference between PTAS and FPTAS?
Both give (1+ε)-approx; FPTAS runs in time polynomial in n AND 1/ε, PTAS only in n (can be exponential in 1/ε). Every FPTAS is a PTAS.
Does general (non-metric) TSP have a constant-factor approximation?
No (unless P=NP).
Common myth about "2-approximation"?
It is NOT a probability/percentage; it's a deterministic worst-case bound: ALG ≤ 2·OPT always.

Concept Map

motivate

runs in

guarantees

min case ALG/OPT le rho

max case ALG/OPT ge rho

proven via

LB le OPT gives

solved by

picked edges form

lower bound LB = size of M le OPT

adds 2 verts per edge, ALG = 2 times size of M

yields

NP-hard problems

Approximation algorithm

Polynomial time

Approximation ratio rho

Minimization

Maximization

Bound on OPT, not OPT itself

ALG le rho*LB le rho*OPT

Vertex Cover

Maximal matching algorithm

Matching M

2-approximation

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, kuch problems (jaise Vertex Cover, TSP) NP-hard hote hain — matlab exact best answer fast nikalna almost impossible. Toh hum perfectionism chhod dete hain. Approximation algorithm fast chalta hai aur ek guarantee deta hai: "mera answer optimal se zyada se zyada itna hi bura hoga." Yeh "itna bura" wala factor hi approximation ratio hai. 2-approximation ka matlab: cost kabhi bhi optimal ke double se zyada nahi — har input pe, hamesha (yeh probability nahi hai bhai, worst-case guarantee hai).

Sabse mast trick: hume OPT pata hi nahi hota (wahi toh problem hai!). Toh hum ek lower bound (LB) dhundhte hain jo OPT se chhota ya barabar ho. Phir do step: (1) prove karo ki ALG ≤ ρ·LB, aur (2) kyunki LB ≤ OPT, automatically ALG ≤ ρ·LB ≤ ρ·OPT. Vertex Cover mein LB = matching size |M| — har disjoint edge ko cover karne ke liye kam se kam 1 vertex chahiye, toh |M| ≤ OPT. Aur hum har matched edge ke dono endpoints daalte hain, toh ALG = 2|M| = 2·LB ≤ 2·OPT. OPT ko jaane bina ratio prove ho gaya!

Yahi LB-LADDER pattern har minimization proof mein milega: pehle apne algorithm ko ρ times ek Lower Bound se compare karo, phir woh LB OPT se chhota hai toh free mein OPT tak pahunch jaao. Metric TSP mein LB = MST ka cost (tour se ek edge hatao toh spanning tree, toh MST ≤ OPT). Load balancing mein do lower bounds — average load aur biggest job — dono ko jodke 2·OPT mil jata hai. Teen yaad rakho: Matching, MST, Average.

Yaad rakhna: "2-approx" matlab 50% chance ya 50% galat nahi hota. Aur non-metric (bina triangle inequality) TSP pe shortcutting wala trick mat lagana — general TSP ka koi constant-factor approximation hota hi nahi (jab tak P=NP na ho).

Go deeper — visual, from zero

Test yourself — Theory of Computation

Connections