Lecture 27
Lecture 27
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