0% found this document useful (0 votes)
9 views

Lecture 27

Uploaded by

f20212599
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Lecture 27

Uploaded by

f20212599
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

BITS, PILANI – K. K.

BIRLA GOA CAMPUS

Design & Analysis of Algorithms


(CS F364)

Lecture No. 27

1
NP Complete Problems
We have proved the following reductions:
CIRCUIT-SAT
SAT
3-CNF
MAX 2SAT MAX-CLIQUE Subset Sum
Vertex Cover Independent Set Set Partition
Hamiltonian Cycle 0-1 Knapsack Bin Packing
TSP Longest Simple Cycle Hamiltonian Path
Longest Simple Path
Coping with NP-hardness
Brute-force algorithms
1. Develop clever enumeration strategies.
2. Guaranteed to find optimal solution.
3. Typically exponential time algorithm
Heuristics/Backtracking Algorithms
1. Develop intuitive algorithms.
2. Not Guaranteed to run in polynomial time.
Approximation algorithms
1. Guaranteed to run in polynomial time.
2. Guaranteed to get a solution which is close to the optimal solution
3. Main Problem:
Need to prove a solution’s value is close to optimum value, without
even knowing what the optimum value is !
Approximation Algorithm
Assume that we are working on an optimization problem in
which each potential solution has a positive cost.
We say that an approximation algorithm for the problem
has a approximation ratio of ρ(n) if for any input of size n,
the cost C of the solution produced by the approximation
algorithm is within a factor of ρ(n) of the cost C* of an
optimal solution:
𝑪 𝑪∗
𝒎𝒂𝒙 ∗ , ≤ 𝝆(𝒏)
𝑪 𝑪
If an algorithm achieves an approximation ratio of ρ(n), it is
called a ρ(n)-approximation algorithm
Approximation Algorithm
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.
Similarly, 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.
The approximation ratio of an approximation algorithm is
never less than 1, since C/C* < 1 implies C*/C > 1
An optimal algorithm has approximation ratio 1
Approximation algorithm with a large approximation ratio
may return a solution that is very much worse than optimal.
Approximation Algorithm
Types of Approximation Algorithm:
• For many problems, approximation algorithms have
been developed that have a fixed approximation
ratio, independent of n.
• For many problems, there are no polynomial-time
approximation algorithm having a fixed
approximation ratio. For such problems, the best
that can be done is to let the approximation ratio
grow as a function of the input size n.
Approximation Algorithm
An approximation scheme for an optimization problem is an
approximation algorithm that takes as input not only an instance
of the problem, but also a value ε > 0 such that for any fixed ε ,
the scheme is an (1 + ε )-approximation algorithm .
We say that an approximation scheme is a polynomial-time
approximation scheme if for any fixed ε > 0, the scheme runs in
time polynomial in the size n of its input instance.
The running time of a polynomial-time approximation scheme
should not increase too rapidly as ε decreases.
We say that an approximation scheme is a fully polynomial-time
approximation scheme if it is a approximation scheme and its
running time is polynomial both in 1/ε and in the size n of the
input instance.
Vertex Cover
Approx-Vertex Cover
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

The running time of this algorithm is O(E)


Vertex Cover - Example
Example:
The edge (b, c), is the
first edge chosen.
Vertices b and c, are
added to the vertex
cover. Edges (a, b),
(c, e), and (c, d), are
removed

vertex cover produced, contains The optimal vertex cover contains


the six vertices b, c, d, e, f, g. only three vertices: b, d, and e.
Vertex Cover
Theorem: Approx-Vertex Cover is a polynomial time
2-approximation algorithm.
Proof:
The algorithm loops until every edge in E has been covered by
some vertex in C.
Therefore, the set C of vertices that is returned by APPROX-
VERTEX-COVER is a vertex cover.
Also, the running time of this algorithm is O(E).
Next, let A denote the set of edges that were picked by the
algorithm.
Observe:
No two edges in A share an endpoint.
Since once an edge is picked, all other edges that are incident on
its endpoints are deleted from E.
Vertex Cover
Any vertex cover and so in particular the optimum
vertex cover (say C*) must cover every edge in A.
Hence, C* contains at least one of the end points of
each edge in A.
And therefore we have the lower bound, |C*| ≥ |A|
Next, every time an edge is chosen by the algorithm
two new vertices are added to C.
Therefore, |C| = 2 |A|.
Combining the two equations we get
|C| = 2 |A|≤ 2 |C*|
Vertex Cover
Important Question:
Is the approximation ratio 2 a tight bound?
i.e. Does there exist instance for which the Approx-
Vertex Cover return solution with approximation ratio
2.
Example: Consider the following complete bipartite
graph

Our algorithm always produces a cover C of size 4.


But, clearly the optimal solution size = 2
Vertex Cover
Alternate Greedy Algorithm
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
Exercise:
Give an example to show that the above algorithm does not
have an approximation ratio of 2.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy