In an optimization problem, we seek the best solution among a collection of possible solutions

When an optimization problem is NP-hard, no polynomial time algorithm exists unless

In these situations, an alternative is an approximation algorithm designed to find an approximately optimal solution in polynomial time

Recall the - problem, shown here

The optimization version of this problem, --, aims to produce one of the smallest vertex covers among all possible covers

We can give a polynomial time algorithm that produces a vertex cover no more than twice the size of an optimal cover

“On input , where is an undirected graph:

  1. Mark an edge in untouched by any marked edge and repeat this stage
  2. Otherwise output all nodes that are endpoints of marked edges”

Let be the set of nodes outputted, and be the set of edges marked

is twice as large as , and is no larger than a smallest vertex cover , since each edge in must be touched by a unique node in , so works as claimed

-- is an example of a minimization problem

There are also maximization problems

An approximation algorithm is k-optimal if, for a minimization problem, it always finds a solution no more than times optimal, and for a maximization problem, it always finds a solution at least times optimal

I.e. is 2-optimal

The - problem asks for a largest cut (a separation of vertices with the most cut edges) in a graph

While this problem is NP-complete, as before we are able to approximate the problem within a factor of 2 with a simple algorithm

“On input , where is an undirected graph with nodes :

  1. Let and
  2. If moving a single node increases the size of the cut, make that move and repeat this stage
  3. Otherwise output the current cut and halt”

This algorithm makes small local improvements

is at least half optimal, because at every individual node the number of cut edges must be at least as large as the number of uncut edges, or else that node would be shifted to the other side