Approximation Algorithm — Definition, Formula & Example
An approximation algorithm is a fast method for a hard optimization problem that may not find the best answer. It does come with a proof that its answer is never worse than a fixed factor times the best possible answer.
Let be an optimization problem, and let be the optimal objective value on instance . A polynomial-time algorithm is a -approximation algorithm, with , if for every instance it returns a feasible solution that satisfies the bound. For a minimization problem the bound is . For a maximization problem it is . The number is called the approximation ratio. Some authors use for maximization.
Key Formula
Where:
- = Any input instance of the problem
- = Cost of the solution the algorithm returns on I
- = Cost of a best possible solution on I
- = Approximation ratio, a constant at least 1 (minimization form shown)
Worked Example
Problem: Five jobs take 3, 3, 2, 2, and 2 hours. You run Graham's list scheduling on 2 identical machines: take the jobs in that order and give each one to the machine with the smaller current load. This algorithm is proven to keep the finishing time (makespan) within a factor of of optimal on machines. Find its makespan and check it against the guarantee.
Step 1: Run the algorithm. Machine 1 gets 3, and machine 2 gets 3. The loads are tied, so machine 1 gets the first 2 (load 5). Machine 2 gets the next 2 (load 5). Machine 1 gets the last 2. The makespan is the larger final load.
Step 2: Bound the optimum from below. Any schedule must fit 12 hours of work on 2 machines, so some machine runs at least the average. The split {3, 3} and {2, 2, 2} reaches this bound, so the optimum is exactly 6.
Step 3: Compare the result with the guarantee. With , the ratio is , so the guaranteed ceiling is hours. The algorithm's ratio on this input is well under that.
Answer: List scheduling finishes in 7 hours, while the optimum is 6 hours. The ratio is , which is within the proven bound of .
Why It Matters
Many scheduling, routing, and covering problems are NP-hard, so no known algorithm solves every instance exactly in polynomial time. Approximation algorithms give provable answers anyway. Examples include a 2-approximation for vertex cover using a maximal matching, a 2-approximation for metric TSP built from a minimum spanning tree, and greedy set cover within a factor of about . They are a core chapter in undergraduate algorithms courses and are used in operations research and chip layout.
Common Mistakes
Mistake: Treating the ratio seen on one input, such as 7/6 above, as the algorithm's approximation ratio.
Correction: The ratio is a worst-case guarantee that must hold for every instance. Some inputs perform better than . To establish , you need a proof covering all inputs, usually done by comparing the output to a lower bound on OPT, as in Step 2.
