Approximation Algorithm NP NPComplete Problems P NPComplete NP
Approximation Algorithm
NP NP-Complete Problems P NP-Complete • NP: Some Problems: problems in We NPwill that concentrate may not on these be solved problems in polynomial henceforth. time. • P: Problems that can be solved in polynomial time.
• • We cannot solve a NP-Complete Problem in polynomial time (at least we do not believe we can). But, can we solve it approximately. Need to formalize this.
The First Problem
1 2 3 4 5 6 7 . . .
The Second Problem
1 2 3 4 5 6 7 . . . 1
Approximation algorithm in a nutshell: • The algorithm runs in polynomial time. • The approximation ratio is bounded. Challenges: • You are all well versed with the challenge in finding an algorithm with best running time. • But in this course, we will not spend time in optimizing the running time of our algorithm. • How can we compare when we do not even know what optimal answer is? • However, will spend in optimizing the approximation ratio. • Needwe to find a lowertime bound on the optimum answer (in case of minimization problem). • Need to find an upper bound on optimum answer (in case of a maximization problem).
Question: How will you solve this problem?
The First Attempt to Solve the Problem
First attempt: Greedy Vertex Cover Question: Why is this algorithm bad?
a b c d e
The Second Attempt
A matching is a set of edges such no two edges in the set are adjacent to each other. Matched vertex: A vertex adjacent to a matched edge. Matching Maximum Free/Unmatched vertex: A vertex that is not adjacent to any matched edge.
Maximal Matching: A matching is maximal if it is not contained in any other matching. Not maximal, why? Because it is contained in this matching.
Maximal Matching: A matching is maximal if it is not contained in any other matching. • A maximal matching may not be maximum. • In this example, maximum matching = 3 but the maximal matching = 2.
Algorithm for vertex cover: Return all the matched vertices of the maximal matching as the vertex cover.
Question: But does it return a vertex cover?
Correctness of our Algorithm
Calculating the approximation ratio of our algorithm
We now need to calculate the approximation ratio of our algorithm.
Question: 1) Is this analysis tight? 2) Can you design an algorithm whose approximation ratio is better than 2?
• • • Maximal matching = 3 Size of our vertex cover = 6 Minimum Vertex Cover = 3
Question: 1) Is this analysis tight? 2) Can you design an algorithm whose approximation ratio is better than 2? Not possible if Unique Games Conjecture is true.
The Second Problem: The Set Cover Problem
• A set cover problem in which each element lies in exactly 2 sets. • We get a 2 -approximation for this version of the set cover problem.
Second Algorithm for Set Cover
Greedy Set Cover Size = 2
• Convince yourself that the algorithm indeed returns a set cover. • And the running time of this algorithm is polynomial in the input size.
. . Number of sets in the optimal set cover.
. . Number of sets in the optimal set cover.
Question: 1) Is this analysis tight? 2) Can you design an algorithm whose approximation ratio is better than 2?
a b c d The same example that we used for Vertex Cover. e
Question: 1) Is this analysis tight? 2) Can you design an algorithm whose approximation ratio is better than 2?
- Slides: 45