You are on page 1of 16

Lecture-03

Approximation Algorithms
Some examples:

• Vertex cover problem.


• Traveling salesman problem.
• Set cover problem.

Spring 2003 Approximation Algorithmes 2


The vertex-cover problem
• A vertex-cover of an undirected graph G is a
subset of its vertices such that it includes at
least one end of each edge.
• The problem is to find minimum size of
vertex-cover of the given graph.
• This problem is an NP-Complete problem.

Spring 2003 Approximation Algorithmes 3


The vertex-cover problem …
• Finding the optimal solution is hard (its
NP!) but finding a near-optimal solution is
easy.
• There is an 2-approximation algorithm:
– It returns a vertex-cover not more than twice
of the size optimal solution.

Spring 2003 Approximation Algorithmes 4


The vertex-cover problem …

APPROX-VERTEX-COVER(G)

1 C←Ø
2 E′ ← E[G]
3 while E′ ≠ Ø
4 do let (u, v) be an arbitrary edge of E′
5 C ← C U {u, v}
6 remove every edge in E′ incident on u or v
7 return C

Spring 2003 Approximation Algorithmes 5


The vertex-cover problem …

Near Optimal Optimal


size=6 Size=3

Spring 2003 Approximation Algorithmes 6


The vertex-cover problem …

• This is a polynomial-time
2-aproximation algorithm. (Why?)
– Because:
• APPROX-VERTEX-COVER is O(V+E)
• |C*| ≥ |A|
Selected Edges
Optimal |C| = 2|A|
|C| ≤ 2|C*|

Selected Vertices

Spring 2003 Approximation Algorithmes 7


The set-Cover
• Generalization of vertex-cover problem.
• We have given (X,F) :
– X : a finite set of elements.
– F : family of subsets of X such that every
element of X belongs to at least one subset in
F.
– Solution C : subset of F that Includes all the
members of X.

Spring 2003 Approximation Algorithmes 8


The set-Cover …

Minimal
Covering set
size=3

Spring 2003 Approximation Algorithmes 9


The set-Cover …
GREEDY-SET-COVER(X,F)
1M←X
2C←Ø
3 while M ≠ Ø do
4 select an SЄF that maximizes |S ‫ ח‬M|
5 M←M–S
6 C ← C U {S}
7 return C

Spring 2003 Approximation Algorithmes 10


The set-Cover …
1st chose

3rd chose

2nd chose
Greedy
Covering set
size=4

4th chose

Spring 2003 Approximation Algorithmes 11


The set-Cover …
• This greedy algorithm is polynomial-time
ρ(n)-approximation algorithm

– ρ(n)=H(max{|S| : S Є F})

Spring 2003 Approximation Algorithmes 12


Set Cover
Theorem: GREEDY-SET-COVER is a
polynomial-time r(n)-approximation algorithm
for
r (n)  H (max{| S |: S  F })

Proof: 1 d
dth harmonic number H d    H (d )
i 1 i

Algorithm runs in time polynomial in


n.
Si  ith subset selected selecting Si costs 1

cx  cost of element x  X paid only when x is covered for the first time

1 assume x is covered for the first time by Si


cx  (spread cost evenly across all elements covered for first time by Si )
Si  ( S1  S 2    Si 1 ) Number of elements covered for first time by Si
Set Cover (proof continued)
Theorem: GREEDY-SET-COVER is a
polynomial-time r(n)-approximation algorithm
for
r (n)  H (max{| S |: S  F })

Proof: (continued)

1 unit is charged at
Let C * be an optimal cover C  c
x X
x each stage of
algorithm
C be cover from GREEDY - SET - COVER

   
Cost assigned to
optimal cover:
   cx 
S C * xS 
in >= 1    cx   x
Each x is

S in C* SC * xS X
cx

 
C     cx 
SC * xS 
Set Cover (proof continued)
Theorem: GREEDY-SET-COVER is a
polynomial-time r(n)-approximation algorithm
for
r (n)  H (max{| S |: S  F })

Proof: (continued)

d
1
How does this relate to dth harmonic number H d    H (d )
harmonic numbers?? i 1 i

We’ll show that: c


xS
x  H( S ) For any set S

 H ( S )  C * H (max{ S : S  F })
And then
conclude that: C 
which will finish the proof SC *
Set Cover (proof continued)

Proof of: c
xS
x  H( S )

For some set S: Number of elements of S u0 | S |


ui | S  ( S1  S 2   Si ) | remaining uncovered after S1…Si selected
 k
1  k = least index for
 c x   

i 1 
(u i 1  u i )
S i  ( S1  S 2    S i 1 )

 which uk=0.
xS 
 k
1  Since, due to greedy | Si  ( S1  S 2   Si 1 ) | 

xS
c x    (u
 i 1
i 1 
 ui ) 
ui 1  nature of algorithm: | S  ( S1  S 2   Si 1 ) | ui 1
k ui 1
 
1  ui1 1 ui 1 
k ui 1
1 since j <= u
 
k
i-1       
i 1 j ui 1 ui 1 i 1 j ui 1 j i 1  j 1 j j 1 j 

k
  H (ui 1 )  H (ui )   H (u0 )  H (u k )  H (u0 )  H (0)  H (u0 )  H ( S )
i 1
telescoping sum

You might also like