An optimization problem can matter even when we do not know how to solve every instance exactly in practical time. We can sometimes settle for a feasible answer with a proved bound on how far it may be from the optimum. That is the aim of an approximation algorithm.
Background for this page. An optimization problem asks for the best feasible value. A lower bound on a minimization optimum says no solution can cost less. Approximation compares an achievable answer with that unknown optimum. Related explanations: Minimum spanning trees: Kruskal, Prim, and safe edges · P, NP, reductions, and NP-completeness.
For a minimization problem with positive costs, a 2-approximation returns an answer costing at most twice the optimum. For a maximization problem, the direction changes: we want a value at least some stated fraction of the optimum. A guarantee applies to every input satisfying its assumptions. It is stronger than saying that an algorithm looked good on examples.
In vertex cover, we choose vertices so every edge has at least one chosen endpoint. One simple method repeatedly picks any uncovered edge, takes both its endpoints, and removes edges they cover. The picked edges form a matching. Any cover must take at least one endpoint of each picked edge, while this method takes two. Its cover therefore has at most twice as many vertices as an optimum cover. The proof is short because the matching gives a lower bound on the optimum.
The traveling-salesperson problem asks for a minimum-cost tour. If distances are nonnegative, symmetric, and obey the triangle inequality, we can build a minimum spanning tree, walk around it, then shortcut repeated vertices. The tree costs no more than the best tour, and the doubled walk costs twice the tree, giving a 2-approximation under those metric assumptions. If distances do not obey the triangle inequality, the shortcut argument fails.
For set cover, repeatedly choosing a set that covers the most still-uncovered items per unit cost gives a logarithmic approximation guarantee under the usual formulation. An approximation method for subset sum shows another direction: trim a list of candidate sums to get a solution arbitrarily close to the best one within a chosen error tolerance, with running time depending on that tolerance. This is the idea of an approximation scheme, where asking for greater accuracy costs more work.
Approximation is one option among several. An exact method may be fine for small inputs. A useful restricted case may have a fast exact solution. A heuristic may perform well but have no proven bound. The choice depends on the cost of error, the size and shape of real inputs, and what guarantee the application needs.
Follow the vertex-cover proof on a path
Take path A–B–C–D. Select edge A–B, include both endpoints, and remove every edge they cover. Only C–D remains; select both endpoints. The algorithm returns four vertices. The two selected edges have no shared endpoint, so every cover needs at least two vertices. A cover of size two exists, such as B and C. The result therefore reaches the factor-two bound in this example.
The algorithm must discard all edges covered by the selected endpoints. Otherwise a later selected edge could share an endpoint with an earlier one, breaking the matching lower-bound argument.
A proved factor is a worst-case guarantee, not a promise that every result is exactly that far from optimum. Feasibility must be checked before discussing the factor.
Practice. A vertex-cover method chooses six vertices and proves that every cover needs at least three. What approximation ratio has it shown for this input? Can the metric traveling-salesperson argument be used unchanged when one direct edge costs more than a detour through another city?
Answer. The six-vertex answer is at most twice the proved lower bound of three, giving a ratio of at most 2 for this input. No. The shortcut step depends on the triangle inequality; when it fails, skipping a detour can increase cost.
Try another case. If an algorithm returns a feasible cost of twelve and a valid lower bound is ten, what ratio can you certify?
Reasoning. At most 1.2 for that instance. The optimum is at least ten, so twelve divided by the optimum cannot exceed twelve divided by ten.