Repository Guide | English | 한국어
Last Updated: 2026-11-04
Introduction to Algorithms, Cormen, Leiserson, Rivest, and Stein, Ch 35
Learning Objectives:
- State, among the three things one can give up when facing an NP-Complete problem (polynomial time, all inputs, optimality), which one an approximation algorithm gives up, define the approximation ratio, and explain the chicken-and-egg problem that computing it requires an optimal value no known method finds in polynomial time
- Apply the indirect-optimal technique, the universal proof template of sandwiching a computable lower or upper bound on OPT, to minimization and maximization problems
- Execute the MST-based 2-approximation for TSP (MST, DFS traversal, duplicate removal), show where the triangle inequality is needed, and prove
$\rho < 2$ - Execute the maximal-matching 2-approximation for Vertex Cover and show that the ratio is tight with an input on which it is exactly 2
- Execute the four Bin Packing heuristics (First Fit, Next Fit, Best Fit, Worst Fit) and the earliest-finishing-machine greedy for Job Scheduling, and prove
$\rho \leq 2$ for each via the at-most-one-bin-at-most-half-full argument and two lower bounds (volume, per-job)- Execute the farthest-first traversal for k-Clustering, prove
$\rho \leq 2$ via the virtual$(k+1)$ -th center and the pigeonhole principle, and compare the time complexity and indirect-optimal bound of all five algorithms in a summary table
- 1. Approximation Algorithms: Foundations
- 2. TSP: MST-Based 2-Approximation
- 3. Vertex Cover: Maximal-Matching 2-Approximation
- 4. Bin Packing: Four Greedy Heuristics
- 5. Job Scheduling: Earliest-Finishing-Machine 2-Approximation
- 6. k-Clustering: Farthest-First 2-Approximation
- 7. Approximation Algorithms: Summary Table
- Summary
- Self-Check Questions
NP-Complete problems appear everywhere in the real world, in routing, scheduling, packing, covering, and clustering, yet no polynomial-time algorithm has ever been found for any of them. As Week 13 showed, if even one were solved in polynomial time, all of them would be. So what do we actually do in practice?
To deal with an NP-Complete problem we must give up one of the following three.
- Finding a solution in polynomial time.
- Finding a solution for all inputs.
- Finding the optimal solution.
Approximation algorithms give up (3): they find a near-optimal solution in polynomial time, with a provable quality guarantee.
| Strategy | Gives up | Characteristics |
|---|---|---|
| Approximation algorithm | (3) optimality | Polynomial time + provable ratio guarantee |
| Heuristic | (3) optimality | Polynomial time but no provable guarantee |
| Exact exponential alg. | (1) polynomial time | Optimal but practical only for small inputs |
| Randomized algorithm | (2) all inputs (probabilistically) | Fast and correct with high probability |
Table 1. Strategies for NP-Complete problems and what each gives up
Key Point: Approximation algorithms produce, in polynomial time, not merely a plausible solution but one whose closeness to optimal is mathematically guaranteed. That guarantee is the approximation ratio.
An approximation algorithm always comes with an approximation ratio
For maximization problems we invert the ratio so that
- The closer
$\rho$ is to$1.0$ , the higher the accuracy. -
$\rho = 2.0$ means a solution within twice the optimum. All five algorithms in Sections 2-6 achieve this 2-approximation. -
The catch: computing
$\rho$ requires OPT, and because the problem is NP-Hard, no known method computes OPT in polynomial time. A clever workaround is needed.
The key idea for sidestepping the chicken-and-egg problem is to find an easily computable bound on OPT instead of computing OPT itself, and to prove the ratio against that.
Minimization problems (TSP, Vertex Cover, Bin Packing, Job Scheduling, and Clustering in Sections 2-6 are all minimization problems):
- Find a computable value
$L$ with$\text{OPT} \geq L$ (a lower bound on OPT). - Show the algorithm's output satisfies
$\text{APX} \leq c \cdot L$ . - Then
$\text{APX} \leq c \cdot L \leq c \cdot \text{OPT}$ , i.e. approximation ratio$c$ .
Maximization problems:
- Find a computable value
$U$ with$\text{OPT} \leq U$ (an upper bound on OPT). - Show the algorithm's output satisfies
$\text{APX} \geq U / c$ . - Then
$\text{APX} \geq U / c \geq \text{OPT} / c$ .
Note: Why it works. The technique never directly computes OPT. It merely sandwiches OPT between two quantities we can control, a computable bound
$L$ and the algorithm's output APX. Every 2-approximation proof in Sections 2-6 follows exactly this template; the only difference is which $L$ we plug in (MST weight, matching size, volume bound, average load, virtual$(k+1)$ -th center distance).
Traveling Salesman Problem (TSP). A salesperson starts from a city, visits every other city exactly once, and returns to the start. Goal: minimize the total travel distance.
Metric TSP makes the following assumptions, which are what make a 2-approximation possible.
-
Symmetry:
$d(A, B) = d(B, A)$ . -
Triangle inequality:
$d(A, B) \leq d(A, C) + d(C, B)$ . That is, a detour is never shorter than the direct route.
Both hold for Euclidean distances and many real-world cost models.
Note: Why the metric assumption is essential. General TSP without the triangle inequality is known to be inapproximable to any constant factor unless
$P = NP$ (provable by a HAM-CYCLE reduction). The triangle inequality is precisely the property guaranteeing that a shortcut is always safe, and it underpins Step 2 of the proof below.
To design a polynomial-time approximation, the standard move is to find a related problem whose efficient algorithm is already known. The Minimum Spanning Tree (MST) shares key properties with TSP.
- MST connects all vertices, just as TSP visits all cities.
- MST minimizes total edge weight, which is related to TSP minimizing tour length.
So we borrow the MST (Week 11) and traverse it to construct an approximate tour.
Approx_MST_TSP (input:
1. Compute the MST of the input graph (Kruskal's or Prim's).
2. Starting from any city, perform a DFS traversal of the MST, recording
the visit order. (Each tree edge is used twice: once forward, once back.)
3. Remove duplicate cities from the visit order: keep only the first
occurrence of each city, then append the starting city at the end.
4. Return the resulting tour.
Step 3 is the shortcut step. Whenever the DFS passes through an already-visited vertex, the tour jumps directly to the next unvisited vertex. The triangle inequality guarantees each shortcut is no longer than the path it replaces.
Consider 8 cities
Step 1: Build the MST. Apply Kruskal's or Prim's algorithm to obtain the tree edges connecting all 8 vertices.
Original graph (partial) MST (Kruskal/Prim result)
A --- B --- C A
| / | / | / \
D --- E --- F ═══> G ...
| / | / \
G ------ H | E D
/ \
H F …
Figure 1. Original graph (partial) and the MST obtained by Kruskal's or Prim's algorithm
Step 2: DFS traversal (starting from
The total length of this traversal is
Step 3: Remove duplicates (shortcut). Skip already-visited cities.
Resulting tour:
By the triangle inequality, each shortcut is no longer than the path it replaces, so the resulting tour length is at most
Claim: Approx_MST_TSP has approximation ratio
Let
Step 1:
[Discrete Mathematics] In Discrete Mathematics a tree is a connected graph with no cycle, and a tree on
$n$ vertices always has$n - 1$ edges. Removing one edge from a Hamiltonian cycle leaves a path that strings all vertices together, a connected graph with no cycle, so it is a spanning tree, and Step 1 uses this fact to compare the weight of the optimal tour with that of the MST.
Step 2:
Combining:
| Step | Operation | Complexity |
|---|---|---|
| 1 | Build MST (Kruskal's) | |
| 1 | Build MST (Prim's) | |
| 2 | DFS traversal | |
| 3 | Remove duplicates |
Table 2. Step-by-step complexity of Approx_MST_TSP
Overall: MST construction dominates, giving
A vertex cover of a graph
Real-world analogy: the problem is like placing the minimum number of CCTV cameras at intersections (vertices) so that every corridor (edge) is monitored.
Example (triangle graph {1, 2, 3}):
-
${1, 2, 3}, {1, 2}, {1, 3}, {2, 3}$ are all vertex covers. - In general, if one vertex touches all edges, that single vertex is the minimum cover. A triangle has no such vertex, so its minimum cover has size 2.
-
${2}$ alone is not a vertex cover because edge$(1,3)$ is uncovered.
In Figure 2, (a) is a graph
Figure 2. Vertex cover example
Key insight: instead of an expensive set-cover-style reduction, use a maximal matching.
- Matching: a set of edges sharing no endpoints.
- Maximal matching: a matching to which no further edge can be added (a greedy stopping point).
- It is not the same as a maximum matching, the largest possible matching. Maximal means it cannot be extended, while maximum means it is the largest.
- A maximal matching can be found greedily in polynomial time.
Idea: select edges greedily only when neither endpoint is already used, then take all endpoints of the selected edges as the vertex cover.
Approx_Matching_VC (input: graph
1. Find a maximal matching M in G:
- M ← ∅
- for each edge (u, v) ∈ E:
if neither u nor v is an endpoint of any edge already in M,
add (u, v) to M.
2. Return the set of all endpoints of edges in M.
Worked example.
graph TD
n1(("1")) --- n2(("2"))
n2 --- n3(("3"))
n1 --- n4(("4"))
n2 --- n4
n2 --- n5(("5"))
n3 --- n5
n3 --- n6(("6"))
n4 --- n5
n5 --- n6
n4 --- n7(("7"))
n5 --- n7
n5 --- n8(("8"))
n6 --- n8
n6 --- n9(("9"))
n7 --- n8
n8 --- n9
Figure 3. Example graph with 9 vertices and 16 edges
If the edges are examined in the order
A matching in a graph with 9 vertices can contain at most 4 edges. In a larger graph, if the greedy maximal matching selected 6 edges, the algorithm would return
Claim: Approx_Matching_VC has approximation ratio
Let
Step 1:
Step 2:
Combining:
Note: The ratio is tight (exactly 2). If the graph consists of
$k$ disjoint edges (a perfect matching of size$k$ with no shared endpoints), the optimal cover takes one endpoint per edge, so it has size$k$ . But the algorithm returns$2k$ endpoints, so$\rho = 2k/k = 2.0$ holds exactly. That is, no ratio better than 2 can be guaranteed for this algorithm. Obtaining a$(2-\epsilon)$ -approximation for any constant$\epsilon > 0$ is known to be NP-Hard if the Unique Games Conjecture holds.
Complexity. If we check whether an edge's endpoints are already used by scanning
Bin Packing Problem. Given
Bin Packing is an NP-Hard optimization problem with rich applications. Examples include memory allocation, container loading, disk partitioning, and virtual-machine packing.
| Method | Strategy |
|---|---|
| First Fit (FF) | Scan bins from the first; place the item in the first bin with enough room. |
| Next Fit (NF) | Check only the most recently used bin; if the item fits, place it there, else open a new bin. |
| Best Fit (BF) | Place the item in the fitting bin that leaves the least remaining space. |
| Worst Fit (WF) | Place the item in the fitting bin that leaves the most remaining space. |
Table 3. Placement strategies of the four Bin Packing heuristics
For all four methods, if no existing bin has room, open a new bin.
| Method | Bin Contents | Bins Used |
|---|---|---|
| First Fit | {7,2}, {5,4}, {6,3}, {7}, {5} | 5 |
| Next Fit | {7}, {5}, {6,4}, {2,3}, {7}, {5} | 6 |
| Best Fit | {7,2}, {5,3}, {6,4}, {7}, {5} | 5 |
| Worst Fit | {7,3}, {5,4}, {6,2}, {7}, {5} | 5 |
| Optimal | {7,3}, {5,5}, {6,4}, {7,2} | 4 |
Table 4. Bin assignments of each heuristic for C = 10
Note: First Fit, Best Fit, and Worst Fit use 5 bins and Next Fit uses 6, while the optimum is 4. The ratios
$5/4 = 1.25$ and$6/4 = 1.5$ are well within the guaranteed 2.0. Next Fit is worst because it looks only at the previous bin and misses the leftover space in earlier bins.
Approx_BinPacking(items s_1, …, s_n, capacity C):
B = 0
for i = 1 to n:
if a bin with enough room exists (per the chosen strategy):
place item i in that bin
else:
open a new bin, place item i in it, B = B + 1
return B
| Method | Per-item work | Total |
|---|---|---|
| First Fit | Scan all bins, |
|
| Best Fit | Scan all bins, |
|
| Worst Fit | Scan all bins, |
|
| Next Fit | Check one bin, |
Table 5. Time complexity of each Bin Packing heuristic
Claim (FF / BF / WF): First Fit, Best Fit, and Worst Fit all achieve
Key observation. At termination, at most one bin can be at most half full.
Why: if two bins were each at most
Proof. Let
The optimum also needs at least
Claim (NF): Next Fit also achieves
Key observation. Under Next Fit, the combined contents of any two consecutive bins exceed
Proof. Group consecutive bins into pairs: (bin 1, bin 2), (bin 3, bin 4), …. There are
Note: Improvement in practice. Sorting items in decreasing size first (First Fit Decreasing, Best Fit Decreasing) yields a much better asymptotic result near
$\frac{11}{9},\text{OPT} + O(1)$ , compared with$1.7,\text{OPT}$ for First Fit. Large items are placed first and small items act as filler for the leftover gaps.
Job Scheduling Problem.
- There are
$n$ jobs with processing times$t_1, t_2, \dots, t_n$ . - There are
$m$ identical machines$M_1, \dots, M_m$ . - Each job runs on exactly one machine without interruption, and each machine processes one job at a time.
Goal: assign jobs to machines to minimize the makespan (the time at which the last job finishes).
Algorithm. Always assign the next job to the machine that finishes earliest (smallest current load).
Approx_JobScheduling(times t_1, …, t_n, m machines):
for j = 1 to m:
L[j] = 0 // current finishing time of machine j
for i = 1 to n:
min = 1
for j = 2 to m: // find the earliest-finishing machine
if L[j] < L[min]:
min = j
assign job i to machine M_min
L[min] = L[min] + t_i
return max(L[1], …, L[m])
Worked example. The jobs are
| Job | Assigned to | Loads after | |
|---|---|---|---|
| 1 | 5 | M1 | [5, 0, 0, 0] |
| 2 | 2 | M2 | [5, 2, 0, 0] |
| 3 | 4 | M3 | [5, 2, 4, 0] |
| 4 | 3 | M4 | [5, 2, 4, 3] |
| 5 | 4 | M2 | [5, 6, 4, 3] |
| 6 | 7 | M4 | [5, 6, 4, 10] |
| 7 | 9 | M3 | [5, 6, 13, 10] |
| 8 | 2 | M1 | [7, 6, 13, 10] |
| 9 | 4 | M2 | [7, 10, 13, 10] |
| 10 | 1 | M1 | [8, 10, 13, 10] |
Table 6. Job-by-job assignment trace of Approx_JobScheduling
Makespan (APX) = 13 (M3).
Claim: Approx_JobScheduling has approximation ratio
Let job
Two lower bounds on OPT:
-
Volume bound:
$\text{OPT} \geq \dfrac{\sum_j t_j}{m}$ . Even with perfect load balancing, some machine must run at least the average. -
Per-job bound:
$\text{OPT} \geq t_i$ . Any schedule must also process job$i$ somewhere, taking$t_i$ time.
Proof. Job
Combining with
Note: Improvement in practice. Longest Processing Time first (LPT), which sorts jobs by decreasing
$t_i$ before the same greedy assignment, achieves a$\frac{4}{3}$ -approximation and performs much better empirically. Placing big jobs first lets small jobs fine-tune the load at the end.
For each of
k-Clustering Problem. Given
Applications: the problem is used in recommendation systems, data mining, VLSI design, parallel processing, web search, pattern recognition, gene analysis, social-network analysis, and more.
Farthest-First Traversal (greedy). Select centers one at a time, each time choosing the point farthest from all existing centers as the next center.
Approx_k_Clusters(points x_0, …, x_{n-1}, k > 1):
C[1] = x_r // random first center
for j = 2 to k:
for each non-center point x_i:
D[i] = min distance from x_i to any existing center
C[j] = the point x_i with the largest D[i] (x_i not already a center)
assign each non-center point to its nearest center
return centers C and cluster assignments
Intuition: spreading centers far apart guarantees that every cluster covers only a small area.
Worked example (
-
Step 1: pick an arbitrary point as
$C_1$ . -
Step 2: compute
$D[i]$ for all non-center points, and choose the point farthest from$C_1$ as$C_2$ . -
Step 3: recompute
$D[i] = \min(d(x_i, C_1), d(x_i, C_2))$ for each point. For example, if$D[1]=18, D[2]=19, D[3]=20, D[4]=17$ and all other values are below 20, the point with the largest value$D[3]=20$ becomes$C_3$ . -
Step 4: recompute
$D[i] = \min(d(x_i, C_1), d(x_i, C_2), d(x_i, C_3))$ , and choose the point with the largest value as$C_4$ . - Step 5: assign each non-center point to its nearest center.
Claim: Approx_k_Clusters has approximation ratio
Setup. After choosing
Step 1:
Step 2:
Combining:
Complexity.
| Component | Analysis |
|---|---|
| Inner loop (each point to centers) | |
| Find max |
|
| Outer loop ( |
|
| Final assignment |
Table 7. Complexity of each component of Approx_k_Clusters
Practical considerations.
-
Random first center: since
$C_1$ is random, results vary between runs. Run several times and take the best result. - Outlier sensitivity: noise and outliers distort center selection, so preprocess the data to remove outliers.
- Legacy: this algorithm is closely related to the k-center problem and is also known as Gonzalez's algorithm (1985). It inspired the k-means++ initialization used in modern k-means.
| Problem | Indirect-Optimal Bound | Ratio | Time |
|---|---|---|---|
| TSP (Metric) |
|
|
|
| Vertex Cover |
|
|
|
| Bin Packing (FF/BF/WF) |
|
||
| Bin Packing (NF) | |||
| Job Scheduling |
|
||
| k-Clustering | virtual |
Table 8. Indirect-optimal bounds, approximation ratios, and time complexities of the five approximation algorithms
All five problems achieve a 2-approximation, guaranteeing a solution at most twice the optimum in polynomial time. The common proof technique is the indirect-optimal technique: find a computable bound on OPT and sandwich OPT between that bound and the algorithm's output.
| Concept | Key Summary |
|---|---|
| Approximation algorithm | An approximation algorithm gives up optimality in exchange for polynomial time and a provable quality guarantee, which distinguishes it from a heuristic with no guarantee. |
| Approximation ratio |
The ratio |
| Indirect optimal | The indirect-optimal technique is the universal proof template that finds a computable lower or upper bound on OPT and sandwiches OPT between that bound and APX. |
| 2-approximation | A 2-approximation guarantees at most twice the optimum, and all five algorithms in Sections 2-6 achieve it. |
| Five canonical algorithms | TSP (MST), Vertex Cover (maximal matching), Bin Packing (FF, NF, BF, WF), Job Scheduling (earliest-finishing machine), and Clustering (farthest-first) all earn a factor-2 guarantee through a simple greedy plus a clean proof. |
| Plugged-in bound |
The proofs differ only in the bound plugged in: MST weight, matching size, volume bound, average load and per-job bound, and virtual |
| Tightness of Vertex Cover | The ratio of 2 is tight because a graph of disjoint edges makes the algorithm produce exactly twice the optimum. |
| Decisive observations | Each proof rests on one decisive assumption or observation that makes the algorithm safe: the triangle inequality for TSP, at most one at-most-half-full bin for Bin Packing, two lower bounds for Job Scheduling, and pigeonhole for Clustering. |
| Overall approach | If a problem cannot be solved exactly, approximate it and prove the quality of the approximation. |
-
The three give-ups: What are the three things one can give up when facing an NP-Complete problem, and which does an approximation algorithm give up? How does it differ from a heuristic?
Answer
The three are (1) polynomial time, (2) all inputs, and (3) optimality. An approximation algorithm gives up (3) optimality while keeping a provable guarantee (the approximation ratio) that the solution is within a fixed factor of optimal. A heuristic also gives up (3) but without a provable guarantee. A heuristic may work well in practice yet offers no mathematical bound on worst-case quality. Whether a provable guarantee exists is the decisive difference between an approximation algorithm and a heuristic.
-
Why indirect optimal: Why does the proof of
$\text{APX} \leq 2 \cdot \text{OPT}$ not compare APX to OPT directly, and how does the indirect bound$L$ act as a substitute?Answer
OPT is what we cannot compute. The whole point of approximation is to avoid computing it. So the proof sandwiches OPT between two quantities we can control: (1) a polynomial-time computable bound
$L$ that we can prove satisfies$L \leq \text{OPT}$ , and (2) the algorithm's output APX, for which we can prove$\text{APX} \leq c \cdot L$ . Combining them gives$\text{APX} \leq c \cdot L \leq c \cdot \text{OPT}$ without ever computing OPT. Every 2-approximation proof in Sections 2-6 plugs in a different$L$ , such as MST weight, matching size, volume bound, average load, or virtual$(k+1)$ -th center distance. -
TSP triangle inequality: Where exactly is the triangle inequality used in the Approx_MST_TSP proof? What breaks without it?
Answer
The triangle inequality is used in algorithm Step 3 (shortcut) and proof Step 2 (
$\text{APX} \leq 2M$ ). When replacing a sub-path$x \to y \to z$ of the DFS traversal with the direct edge$x \to z$ , we need$d(x, z) \leq d(x, y) + d(y, z)$ . Otherwise a shortcut could be longer than the path it replaces, breaking the$\text{APX} \leq 2M$ bound. Without the triangle inequality, general TSP cannot be approximated to any constant factor unless$P = NP$ , because for any constant$\rho$ , transforming a HAM-CYCLE instance$G$ into a TSP instance that gives weight 1 to the edges of$G$ and weight$\rho|V| + 1$ to all other edges lets a$\rho$ -approximation algorithm decide HAM-CYCLE. Metric TSP is the well-behaved case where the triangle inequality makes shortcutting safe. -
TSP's
$\text{OPT} > M$ step: Explain why the optimal TSP tour length exceeds the MST weight.Answer
The optimal tour is a cycle visiting all
$n$ vertices and returning to the start. Removing any one edge from that cycle leaves a spanning tree that connects all vertices, preserves connectivity, and has$n-1$ edges. Since the MST is the minimum spanning tree, its weight$M$ is at most the weight of that spanning tree (the tour minus one edge). Assuming positive edge weights,$M \leq \text{OPT} - (\text{removed edge}) < \text{OPT}$ . Hence$M < \text{OPT}$ , which provides the lower bound$L = M$ for the TSP proof. -
Vertex Cover tightness: Give an input where the maximal-matching algorithm returns a cover exactly twice the optimum, and explain what this means.
Answer
Take a graph consisting of
$k$ disjoint edges, that is, a perfect matching of size$k$ with no shared endpoints. The optimal vertex cover takes one endpoint per edge, so it has size$k$ . But the algorithm selects all$k$ edges into the maximal matching and returns$2k$ endpoints, so$\rho = 2k/k = 2.0$ holds exactly. This means the algorithm's 2-approximation guarantee is tight, and no ratio better than 2 can be guaranteed for this algorithm. Beating 2 requires a fundamentally different approach. -
Bin Packing key observation: Justify the observation, used in the FF/BF/WF proof of
$\rho \leq 2$ , that at most one bin is at most half full.Answer
Suppose two bins
$B_1, B_2$ are both at most half full (at most$C/2$ ). Then their combined contents are at most$C/2 + C/2 = C$ , so they would fit in a single bin. But FF/BF/WF always try to place an item into an existing bin before opening a new one, so the first item of the later-opened bin could not have fit into the earlier bin. This is a contradiction. Hence at most one bin is at most half full. Consequently at least$\text{OPT}'-1$ bins are more than half full, giving$\sum s_i > (\text{OPT}'-1)\cdot C/2$ , and combining this with$\text{OPT} \geq \sum s_i/C$ yields$2,\text{OPT} \geq \text{OPT}'$ . -
Why Next Fit is worse: In the Section 4.3 example Next Fit uses 6 bins versus 5 for the other heuristics. Explain this by the algorithm's behavior.
Answer
Next Fit checks only the most recently opened bin and opens a new bin the moment an item does not fit. It never looks back at earlier bins even if they have room. In the example, when processing the 6 it looks only at the previous bin {5} (the 6 does not fit) and opens a new bin, and it never returns to the {7} bin afterwards. So the later items 2 and 3 cannot use the remaining space of 3 in the {7} bin and occupy a new bin {2,3}. First Fit, Best Fit, and Worst Fit instead scan all open bins and reuse earlier leftover space. The trade-off is that Next Fit is faster, at
$O(1)$ per item and$O(n)$ overall, while the others are$O(n^2)$ . -
Job Scheduling's two bounds: Why does the makespan proof need both lower bounds on OPT? Why is one insufficient?
Answer
With the last-finishing job
$i$ starting at time$T$ and taking$t_i$ ,$\text{APX} = T + t_i$ . (1) The volume bound$\text{OPT} \geq \sum t_j/m$ gives$T \leq \text{OPT}$ (the greedy placed job$i$ on the earliest-finishing machine, so$T$ is at most the average). (2) The per-job bound$\text{OPT} \geq t_i$ gives$t_i \leq \text{OPT}$ . Both are needed for$\text{APX} = T + t_i \leq \text{OPT} + \text{OPT} = 2,\text{OPT}$ . One alone is insufficient. The volume bound cannot handle a huge$t_i$ that dominates the average, in which case a single large job can dominate the makespan. The per-job bound cannot handle many small jobs accumulating into a large$T$ . Both cases must be blocked for the 2-approximation to hold. -
Clustering pigeonhole: Detail the pigeonhole step of the
$\text{OPT} \geq d$ argument with$k = 3$ and 4 centers including the virtual one.Answer
The chosen
$k=3$ centers$C_1, C_2, C_3$ plus the virtual$C_4$ make 4 center points. The optimal solution partitions all points into 3 clusters. By the pigeonhole principle, distributing 4 items into 3 bins forces at least one bin to hold 2 or more items. That is, some optimal cluster contains at least 2 of${C_1, C_2, C_3, C_4}$ . The diameter of that cluster is at least the distance between its two centers, and since the minimum pairwise distance among the four centers is$d$ by the farthest-first construction, that diameter is$\geq d$ . Hence the maximum cluster diameter is$\geq d$ , that is,$\text{OPT} \geq d$ . Combined with Step 2's$\text{APX} \leq 2d$ , this gives$\rho \leq 2$ . -
Ratio vs complexity trade-off: All five algorithms achieve
$\rho \leq 2$ , yet complexities range from$O(n)$ (Next Fit) to$O(k^2 n)$ (Clustering). What drives the complexity difference at the same ratio?Answer
The ratio guarantee (2) comes from the proof structure (indirect optimal), while complexity comes from how many candidates the algorithm inspects per step. Next Fit checks one bin, so it runs in
$O(n)$ . First Fit, Best Fit, and Worst Fit scan all bins per item, so they run in$O(n^2)$ . TSP is dominated by MST construction, so it runs in$O(n^2)$ or$O(m\log m)$ . Vertex Cover and Job Scheduling do a linear check per edge or job, so they run in$O(nm)$ . Clustering multiplies an outer loop of$k-1$ iterations by an inner$O(kn)$ , giving$O(k^2 n)$ . The key point is that a greedy that examines more global information (all bins, all machines, all centers) usually yields better practical solutions but the same worst-case guarantee of 2. The ratio is a worst-case bound, not average performance. -
Approximation vs exact: 0-1 Knapsack is solved by an
$O(nC)$ DP, so why is it still a target for approximation algorithms and heuristics? (Week 13 connection)Answer
The
$O(nC)$ DP is pseudo-polynomial: polynomial in the value of the capacity$C$ but exponential in the input bit-length ($\log C$ bits). For instances like$C \approx 2^{100}$ it is impractical, and the NP-Completeness proof constructs exactly such instances with exponentially large$C$ . So for general large$C$ the exact DP fails and we turn to approximation algorithms (e.g. an FPTAS) or heuristics. This ties directly to the Week 13 point that polynomial time means polynomial in the encoding length, not the value. -
Greedy improvement pattern: What improvement idea do Bin Packing's FFD (First Fit Decreasing) and Job Scheduling's LPT (Longest Processing Time) share?
Answer
Both process the large items or jobs first and let the small ones act as filler for the leftover gaps at the end. In an arbitrary order, small items occupy resources early, forcing later large items into their own nearly empty bins or machines. Sorting in decreasing order places big items first, when there is plenty of room, and then lets small items precisely fill the remaining space. As a result FFD achieves
$\frac{11}{9},\text{OPT}+O(1)$ and LPT a$\frac{4}{3}$ -approximation, beating the 2-approximation of plain FF and the plain greedy. The general lesson is that in many greedy approximations, handling the chunky items first lets small items serve as load fine-tuning, greatly improving packing and scheduling efficiency. -
LPT improvement for Job Scheduling: Sketch why scheduling jobs in Longest Processing Time First order achieves a
$4/3$ approximation instead of$2$ .Answer
With LPT, the job
$i$ that determines the makespan was assigned after all larger jobs, so it is among the smaller jobs. There are two cases. Case A: if$t_i \leq \text{OPT}/3$ , then reusing the volume bound$T \leq \text{OPT}$ from the 2-approximation proof gives$\text{APX} = T + t_i \leq \text{OPT} + \text{OPT}/3 = (4/3),\text{OPT}$ . Case B: if$t_i > \text{OPT}/3$ , then every job processed up to and including job$i$ also has size$> \text{OPT}/3$ (LPT processed them earlier, so they are at least as large). Each optimal machine can hold at most two such jobs (three would exceed$\text{OPT}$ ), so there are at most$2m$ such jobs. For such instances, with at most$2m$ jobs and at most two jobs per optimal machine, LPT is known to produce an optimal schedule, so$\text{APX} = \text{OPT} \leq (4/3),\text{OPT}$ . Either way$\text{APX} \leq (4/3)\cdot\text{OPT}$ . Conceptually, putting large jobs first lets the small jobs serve as load-balancing slack at the end, where mismatches matter less.
