Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 256 Data Structures and Algorithm Analysis Lecture 22 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some.

Similar presentations


Presentation on theme: "CSCI 256 Data Structures and Algorithm Analysis Lecture 22 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some."— Presentation transcript:

1 CSCI 256 Data Structures and Algorithm Analysis Lecture 22 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some by Iker Gondra

2 Transition point Till now we’ve looked at developing efficient algorithms for a wide range of problems Now we look to quantify or characterize the range of problems that can’t be solved efficiently We’ll use the notion of reduction to help compare the relative difficulty of different problems

3 The Universe NP-Complete NP P Millennium Prize Problems Copyright © 1990, Matt Groening

4 Classify Problems According to Computational Requirements Q: Which problems will we be able to solve in practice? –A working definition. [Cobham 1964, Edmonds 1965, Rabin 1966] Those with polynomial-time algorithms Desiderata: Classify problems according to those that can be solved in polynomial-time and those that cannot Frustrating news: Huge number of fundamental problems have defied classification for decades – i.e. can’t give a poly time alg and can’t prove that none exists This chapter: Show that these fundamental problems are "computationally equivalent" and appear to be different manifestations of one really hard problem

5 Polynomial-Time Reduction Desiderata': Suppose we could solve Y in polynomial-time. What else could we solve in polynomial time? Reduction: Problem X polynomial reduces to problem Y if arbitrary instances of problem X can be solved using –Polynomial number of standard computational steps, plus –Polynomial number of calls to an oracle (a black box) that solves problem Y Notation: X  P Y computational model supplemented by special piece of hardware that solves instances of Y in a single step

6 Lemma Suppose X  P Y. If Y can be solved in polynomial time, then X can be solved in polynomial time Remark – when you are reading the text note that the text talks of Y  P X

7 Lemma Suppose X  P Y. If X cannot be solved in polynomial time, then Y cannot be solved in polynomial time

8 Polynomial-Time Reduction Purpose: Classify problems according to relative difficulty Design algorithms: If X  P Y and Y can be solved in polynomial-time, then X can also be solved in polynomial time Establish intractability: If X  P Y and X cannot be solved in polynomial-time, then Y cannot be solved in polynomial time Establish equivalence: If X  P Y and Y  P X, we use notation X  P Y up to cost of reduction

9 Independent Set –Goal is to find S of maximum size 1 3 2 6 7 4 5

10 Decision Problem Call the above an optimization version of the problem There is another way to formulate the problem – as a decision problem A decision problem is a class of problems for which there is a yes or no answer for each instance of the problem. We rephrase the Independent Set problem as the following decision problem

11 Independent Set – Decision version - Given a graph G = (V, E) and an integer k, does G contain an independent set of size at least k? –Ex: Instance: For G below, is there an independent set of size  6? Yes –Ex: Instance: For G below, is there an independent set of size  7? No independent set Sample Application: find set of mutually non-conflicting points

12 Equivalence between decision and optimization versions Given a method to solve the optimization version, we automatically solve each instance of the associated decision problem; and if we have a method to solve each instance of the decision then we can solve the optimization version (for given G, the the largest k for which there is a yes answer gives us the answer to the optimization version for G)

13 Vertex Cover –Given a graph G = (V, E), a subset S of the vertices is a vertex cover if every edge in E has at least one endpoint in S. Goal is to find S of minimum size 1 3 2 6 7 4 5

14 Vertex Cover – Associated decision version – if you can do optimization version you can do decision version and vice versa Convert to decision version of the problem –Given a graph G = (V, E) and an integer k, does G contain a vertex cover of size at most k? –Ex: Instance: For G, Is there a vertex cover of size  4? Yes –Ex: Instance: For G, Is there a vertex cover of size  3? No vertex cover Sample Application: place guards within an art gallery so that all corridors are visible at any time

15 Relative difficulty of the two problems We don’t know how to solve the independent set problem or vertex cover problem in polynomial time; but we can show that they are equivalently hard First we need the following theorem:

16 Vertex Cover and Independent Set Theorem: S is an independent set iff V  S is a vertex cover. Recall: Given a graph G = (V, E), a subset S of the vertices is independent if there are no edges between vertices in S. Recall: Given a graph G = (V, E), a subset S of the vertices is a vertex cover if every edge in E has at least one endpoint in S.

17 Vertex Cover and Independent Set Theorem: S is an independent set iff V  S is a vertex cover  –Let S be any independent set –Consider an arbitrary edge, (u, v) ε E –S independent  u  S or v  S  u  V  S or v  V  S –Thus, V  S covers (u, v)  –Let V  S be any vertex cover –Consider two nodes u  S and v  S –Observe (u, v)  E (V  S is a vertex cover so if (u,v) ε E, u  V- S or v  V – S so u  S or v  S -- a contradiction –Thus, no two nodes in S are joined by an edge  S indep set

18 Vertex Cover and Independent Set Reductions to each other: Theorem: VERTEX-COVER  P INDEPENDENT-SET If we have a black box to solve the Vertex Cover problem then we can decide if G has an independent set of size at least k by asking the black box whether G has a Vertex Cover of size at most n-k. Conversely if we have a black box to solve the Independent set problem we can decide if G has a vertex cover problem of size at most k by asking the black box if G has an independent set of size at least n-k

19 Set Cover SET COVER: Given a set U of elements, a collection S 1, S 2,..., S m of subsets of U, and an integer k, does there exist a collection of  k of these sets whose union is equal to U? Sample application –m available pieces of software –Set U of n capabilities that we would like our system to have –The ith piece of software provides the set S i  U of capabilities –Goal: achieve all n capabilities using fewest pieces of software U = { 1, 2, 3, 4, 5, 6, 7 } k = 2 S 1 = {3, 7}S 4 = {2, 4} S 2 = {3, 4, 5, 6}S 5 = {5} S 3 = {1}S 6 = {1, 2, 6, 7}

20 Claim: VERTEX-COVER  P SET-COVER –Pf: Given a VERTEX-COVER instance, i.e., a graph G = (V, E), and an integer, k, we construct a set cover instance whose size equals the size of the vertex cover instance, so G has a vertex cover of size k iff for the set U, and subsets S 1, S 2,..., S m of U, there exists a collection of  k of these sets whose union is equal to U

21 Vertex Cover Reduces to Set Cover Claim: VERTEX-COVER  P SET-COVER Construction –Create SET-COVER instance k = k, U = { i | e i  E), S v = { i : e i incident to v } (note S v  U) –Set-cover of size  k iff vertex cover of size  k SET COVER U = { 1, 2, 3, 4, 5, 6, 7 } k = 2 S a = {3, 7}S b = {2, 4} S c = {3, 4, 5, 6}S d = {5} S e = {1}S f = {1, 2, 6, 7} a d b e fc VERTEX COVER k = 2 e1e1 e2e2 e3e3 e5e5 e4e4 e6e6 e7e7


Download ppt "CSCI 256 Data Structures and Algorithm Analysis Lecture 22 Some slides by Kevin Wayne copyright 2005, Pearson Addison Wesley all rights reserved, and some."

Similar presentations


Ads by Google