UNIT 5 Approximation Algorithms
UNIT 5 Approximation Algorithms
APPROXIMATION
ALGORITHMS
Outline of the
lecture
► Background
► Definition of approximation algorithms
► Some examples of approximation
algorithms
► Conclusion
Optimization
Problem
1. Absolute approximation
) A is an absolute approximation algorithm if there exists a
constant k
such that, for every instance I of P , |A∗ (I) − A(I)| ≤ k.
) For example, Planar graph coloring.
2. Relative approximation
∗
) such
A is that, for every
an relative approximation I of P , AA(I)
instancealgorithm if
(I) A(I)
max{there
A ∗ (I)
,
exists a
Vertex k
constant
) } ≤ k.
cover.
Examples we discuss in this
lecture
1. Vertex Cover
2. Traveling Salesman
Problem
3. Bin Packing
1) Vertex
Cover
(a (b
) )
(c) (d)
Figure: (a) An undirected graph (b) A trivial vertex cover (c) A vertex
cover (d) An other vertex cover
Greedy
algorithm 1
1. C ← ∅
2. pick any edge (u, v ) ∈ E .
3. C = C ∪ { u, v }
4. remove all edges incident on either u or v
from E .
5. repeat the process till all edges are removed
from E .
6. return C .
Algorithm 1 with an
example
(a) (b (c)
)
A C
B
(d) (e) (f
)
Figure: Execution of algorithm 1
. .
n n
1. C ← ∅
2. take a vertex v ∈ V of maximum degree (tie can be
broken arbitrarily).
3. C = C ∪ { v }
4. remove all edges incident on v from E .
5. repeat the process till all edges are removed from
E.
6. return C .
Algorithm 2 with an
example
Figure: Execution of
algorithm 2
Algorithm 2 with an
example
Figure: Execution of
algorithm 2
Algorithm 2 with an
example
Figure: Execution of
algorithm 2
Algorithm 2 with an
example
Figure: Execution of
algorithm 2
Algorithm 2 with an
example
Figure: Execution of
algorithm 2
Algorithm 2 with an
example
Figure: Execution of
algorithm 2
Algorithm 2 with an
example
Figure: Execution of
algorithm 2
Performance analysis of
algorithm 2
Generalizing the previous example
k! vertices of degree k
···
·· ··
k! ···
k vertices of ·degree k k!
k 1
·
··· k! vertices of degree 1
1. The verticesvertices
picked ···
by the algorithm forms a vertex
of degree k − 1
cover.
2. The algorithm runs in polynomial time of input size.
3. Optimum solution C ∗ contains all top vertices, |C ∗|
= k!.
5. Hence |C | = k1k!( 1 + · · · + 1) ≈ k! log k = log ∗
4.+Solution C given (k− 1by algorithm
k|C | 2 contains all bottom
vertices.
Open
problem
C2
100
C1
31
66
C3 85
101
20
65
C4 110 C5
Exampl
e
C2
100
∞
C1
31
∞ 66
C3 85
101
20
65
C4 110 C5
Exampl
e
C2
100
∞
C1
31
∞ 66
C3 85
101
20
65
C4 110 C5
Hardne
ss
10 10
40 40
30 20 12 30 20 12
10 10
40 40
30 20 12 30 20 12
10 10
40 40
Analysis of
Algorithm 1
1. The algorithm is closely related to Prim’s MST algorithm.
2. The edges identified form a MST.
3. The cost of the optimal tour is at least the cost of MST on
the same input.
4. The cost of the tour on the first two nodes vi and vj is
exactly 2ci,j .
5. Consider an iteration in which a node vj is inserted between
nodes vi
and vk in the current tour.
6. Increase in the length of the tour is ci,j + cj,k − ci,k .
7. But, by the triangle inequality cj,k ≤ cj,i + ci,k
8. Increase in cost in this iteration is at most ci,j + cj,i = 2ci,j .
9. Hence the final tour has cost at most twice the cost of the
MST.
10. Thus Algorithm 1 is a 2-factor approximation algorithm.
Algorithm 2 : Double tree
algorithm
1. Compute a MST.
2. Replace each edge of MST by two copies
of itself.
3. Find an Eulerian tour.
4. Shortcut the tour to get a Hamiltonian
cycle.
5. Return the Hamilton cycle.
Exampl
e
C2
100
C1
31
66
C3 85
101
20
65
C4 110 C5
Exampl
e
C2
C1
31
66
C3
20
65
C4 C5
Exampl
e
C2
C1 31
31
66
66 C3
20
65 65
20
C4 C5
Exampl
e
C2
C1 31 Eulerian tour
31
66
66 C3 C1 , C3 , C4 , C3 , C5 , C3 , C2 , C3 , C1
20
65 65
20
C4 C5
Exampl
e
C2
10
0 Eulerian tour
C1 C1 , C3 , C4 , C3 , C5 , C3 , C2 , C3 ,
C1
66
C3 8
5 Hamilton Cycle
C 1, C 3, C 4, C 5, C 2, C 1
20
C4 11 C5
0
Analysis of
Algorithm 2
0.2
0.1
0.1
0.2
0.8 0.7
0.5 0.6 0.4
0.4
0.8 0.7
0.4 0.6
0.2
D D D
l×D
D D D
D D D
D D D
1. Basics of approximation.
2. Need of approximation algorithms.
3. Some examples, Vertex cover, TSP, and Bin
packing.
4. PTAS
Some
books