Approximation Algorithms (2)
Approximation Algorithms (2)
Introduction
• Many problems of practical significance are NP-
complete and can be solved in following ways:
1. If the actual inputs are small, an algorithm with
exponential running time may be perfectly
satisfactory.
2. Identify important special cases that can be solved
in polynomial time.
3. Approximation Algorithm
– Algorithms that runs in polynomial time and
always produce a solution close to the optimal.
Performance Ratios
• An algorithm for a problem has an approximation
ratio of ρ(n) if, for any input of size n, the cost C of
the solution produced by the algorithm is within a
factor of ρ(n) of the cost C* of an optimal solution:
C C*
max * , (n)
C C
• If an algorithm achieves an approximation ratio of
ρ(n), it is called as a ρ(n) -approximation algorithm.
• ρ(n) ≥ 1
– 1-approximation algorithm produces an optimal
solution.
Contd…
• Definitions of approximation ratio and ρ(n)-
approximation algorithm can be applied to both
minimization and maximization problems.
• For a maximization problem,
– 0 < C ≤ C*, and the ratio C*/C gives the factor by which
the cost of an optimal solution is larger than the cost of
the approximate solution.
• For a minimization problem,
– 0 < C* ≤ C, and the ratio C/C* gives the factor by which
the cost of the approximate solution is larger than the
cost of an optimal solution.
Traveling Salesman Problem
Traveling Salesman Problem
• Given a complete undirected graph G = (V, E) with
a nonnegative integer cost c(u,v) associated with
each edge (u,v) ϵ E, find a hamiltonian cycle (a tour)
of G with minimum cost.
• Consider two cases:
– with and without triangle inequality.
– c satisfies triangle inequality, if for all vertices u,
v, w ϵ V, c(u,w) ≤ c(u,v) + c(v,w)
• Finding an optimal solution is NP-complete in both
cases.
TSP with Triangle Inequality
• Compute a minimum spanning tree, whose weight
gives a lower bound on the length of an optimal
traveling-salesman tour.
• Use the minimum spanning tree to create a tour
whose cost is no more than twice that of the
minimum spanning tree’s weight, as long as the cost
function satisfies the triangle inequality.
• Assuming,
– G – a complete undirected graph.
– c – a cost function satisfying the triangle
inequality.
APPROX-TSP-TOUR(G,c)
1. Select a vertex r ϵ G.V to be a “root” vertex
22