1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.

Slides:



Advertisements
Similar presentations
Analysis of Algorithms
Advertisements

NP-Hard Nattee Niparnan.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
NP-Completeness: Reductions
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Complexity 11-1 Complexity Andrei Bulatov NP-Completeness.
Approximation Algorithms Lecture for CS 302. What is a NP problem? Given an instance of the problem, V, and a ‘certificate’, C, we can verify V is in.
Reduction Techniques Restriction Local Replacement Component Design Examples.
Transitivity of  poly Theorem: Let ,  ’, and  ’’ be three decision problems such that   poly  ’ and  ’  poly  ’’. Then  poly  ’’. Proof:
Polynomial-Time Reductions
CSE 326: Data Structures NP Completeness Ben Lerner Summer 2007.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Analysis of Algorithms CS 477/677
Time Complexity.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Complexity ©D.Moshkovitz 1 Paths On the Reasonability of Finding Paths in Graphs.
February 25, 2015CS21 Lecture 211 CS21 Decidability and Tractability Lecture 21 February 25, 2015.
NP and Computational Intractability
Prof. Swarat Chaudhuri COMP 482: Design and Analysis of Algorithms Spring 2013 Lecture 22.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 31.
11/3/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURES NP-completeness.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
EECS 203: It’s the end of the class and I feel fine. Graphs.
Nattee Niparnan. Easy & Hard Problem What is “difficulty” of problem? Difficult for computer scientist to derive algorithm for the problem? Difficult.
1 The TSP : NP-Completeness Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell.
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta
CSEP 521 Applied Algorithms Richard Anderson Lecture 10 NP Completeness.
Prabhas Chongstitvatana1 NP-complete proofs The circuit satisfiability proof of NP- completeness relies on a direct proof that L  p CIRCUIT-SAT for every.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Basic genres.  Packing problems: SET-PACKING, INDEPENDENT SET.  Covering problems: S ET-COVER, VERTEX-COVER.  Constraint satisfaction problems: SAT,
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 33.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
EMIS 8373: Integer Programming NP-Complete Problems updated 21 April 2009.
Techniques for Proving NP-Completeness Show that a special case of the problem you are interested in is NP- complete. For example: The problem of finding.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
Unit 9: Coping with NP-Completeness
30.
CS 3343: Analysis of Algorithms Lecture 25: P and NP Some slides courtesy of Carola Wenk.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 29.
28.
NPC.
CSC 413/513: Intro to Algorithms
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 32.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
34.NP Completeness. Computer Theory Lab. Chapter 34P.2.
CSE 332: NP Completeness, Part II Richard Anderson Spring 2016.
ICS 353: Design and Analysis of Algorithms NP-Complete Problems King Fahd University of Petroleum & Minerals Information & Computer Science Department.
The Theory of NP-Completeness
More NP-Complete and NP-hard Problems
More NP-complete problems
Hard Problems Some problems are hard to solve.
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Lecture 24 NP-Complete Problems
ICS 353: Design and Analysis of Algorithms
Richard Anderson Lecture 25 NP-Completeness
Richard Anderson Lecture 28 NP-Completeness
Chapter 8 NP and Computational Intractability
Chapter 8 NP and Computational Intractability
Richard Anderson Lecture 30 NP-Completeness
CS 3343: Analysis of Algorithms
Hamiltonian Circuit (HC) problem
Presentation transcript:

1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.

Basic genres.  Packing problems: SET-PACKING, INDEPENDENT SET.  Covering problems: S ET-COVER, VERTEX-COVER.  Constraint satisfaction problems: SAT, 3-SAT.  Sequencing problems: HAMILTONIAN-CYCLE, TSP.  Partitioning problems: 3D-MATCHING, 3 -COLOR.  Numerical problems: SUBSET-SUM, KNAPSACK. 8.5 Sequencing Problems

3 Hamiltonian Cycle HAM-CYCLE : given an undirected graph G = (V, E), does there exist a simple cycle  that contains every node in V. YES: vertices and faces of a dodecahedron.

4 Hamiltonian Cycle HAM-CYCLE : given an undirected graph G = (V, E), does there exist a simple cycle  that contains every node in V ' 3' 2 4 2' 4' NO: bipartite graph with odd number of nodes.

5 Directed Hamiltonian Cycle DIR-HAM-CYCLE : given a digraph G = (V, E), does there exists a simple directed cycle  that contains every node in V? Claim. DIR-HAM-CYCLE  P HAM-CYCLE. Pf. Given a directed graph G = (V, E), construct an undirected graph G' with 3n nodes. v a b c d e v in a out b out c out d in e in G G' vv out

6 Directed Hamiltonian Cycle Claim. G has a Hamiltonian cycle iff G' does. Pf.  n Suppose G has a directed Hamiltonian cycle . n Then G' has an undirected Hamiltonian cycle (same order). Pf.  n Suppose G' has an undirected Hamiltonian cycle  '. n  ' must visit nodes in G' using one of following two orders: …, B, G, R, B, G, R, B, G, R, B, … …, B, R, G, B, R, G, B, R, G, B, … n Blue nodes in  ' make up directed Hamiltonian cycle  in G, or reverse of one. ▪

7 3-SAT Reduces to Directed Hamiltonian Cycle Claim. 3-SAT  P DIR-HAM-CYCLE. Pf. Given an instance  of 3-SAT, we construct an instance of DIR- HAM-CYCLE that has a Hamiltonian cycle iff  is satisfiable. Construction. First, create graph that has 2 n Hamiltonian cycles which correspond in a natural way to 2 n possible truth assignments.

8 3-SAT Reduces to Directed Hamiltonian Cycle Construction. Given 3-SAT instance  with n variables x i and k clauses. n Construct G to have 2 n Hamiltonian cycles. n Intuition: traverse path i from left to right  set variable x i = 1. s t 3k + 3 x1x1 x2x2 x3x3

9 3-SAT Reduces to Directed Hamiltonian Cycle Construction. Given 3-SAT instance  with n variables x i and k clauses. n For each clause: add a node and 6 edges. s t clause node x1x1 x2x2 x3x3

10 3-SAT Reduces to Directed Hamiltonian Cycle Claim.  is satisfiable iff G has a Hamiltonian cycle. Pf.  n Suppose 3-SAT instance has satisfying assignment x*. n Then, define Hamiltonian cycle in G as follows: – if x* i = 1, traverse row i from left to right – if x* i = 0, traverse row i from right to left – for each clause C j, there will be at least one row i in which we are going in "correct" direction to splice node C j into tour

11 3-SAT Reduces to Directed Hamiltonian Cycle Claim.  is satisfiable iff G has a Hamiltonian cycle. Pf.  n Suppose G has a Hamiltonian cycle . If  enters clause node C j, it must depart on mate edge. – thus, nodes immediately before and after C j are connected by an edge e in G – removing C j from cycle, and replacing it with edge e yields Hamiltonian cycle on G - { C j } Continuing in this way, we are left with Hamiltonian cycle  ' in G - { C 1, C 2,..., C k }. Set x* i = 1 iff  ' traverses row i left to right. Since  visits each clause node C j, at least one of the paths is traversed in "correct" direction, and each clause is satisfied. ▪

12 Longest Path SHORTEST-PATH. Given a digraph G = (V, E), does there exists a simple path of length at most k edges? LONGEST-PATH. Given a digraph G = (V, E), does there exists a simple path of length at least k edges? Claim. 3-SAT  P LONGEST-PATH. Pf 1. Redo proof for DIR-HAM-CYCLE, ignoring back-edge from t to s. Pf 2. Show HAM-CYCLE  P LONGEST-PATH.

13 The Longest Path t Lyrics. Copyright © 1988 by Daniel J. Barrett. Music. Sung to the tune of The Longest Time by Billy Joel. Woh-oh-oh-oh, find the longest path! If you said P is NP tonight, There would still be papers left to write, I have a weakness, I'm addicted to completeness, And I keep searching for the longest path. The algorithm I would like to see Is of polynomial degree, But it's elusive: Nobody has found conclusive Evidence that we can find a longest path. I have been hard working for so long. I swear it's right, and he marks it wrong. Some how I'll feel sorry when it's done: GPA 2.1 Is more than I hope for. Garey, Johnson, Karp and other men (and women) Tried to make it order N log N. Am I a mad fool If I spend my life in grad school, Forever following the longest path? Woh-oh-oh-oh, find the longest path! Woh-oh-oh-oh, find the longest path. t Recorded by Dan Barrett while a grad student at Johns Hopkins during a difficult algorithms final.

14 Traveling Salesperson Problem TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length  D? All 13,509 cities in US with a population of at least 500 Reference:

15 Traveling Salesperson Problem TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length  D? Optimal TSP tour Reference:

16 Traveling Salesperson Problem TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length  D? 11,849 holes to drill in a programmed logic array Reference:

17 Traveling Salesperson Problem TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length  D? Optimal TSP tour Reference:

18 Traveling Salesperson Problem TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length  D? HAM-CYCLE : given a graph G = (V, E), does there exists a simple cycle that contains every node in V? Claim. HAM-CYCLE  P TSP. Pf. n Given instance G = (V, E) of HAM-CYCLE, create n cities with distance function n TSP instance has tour of length  n iff G is Hamiltonian. ▪ Remark. TSP instance in reduction satisfies  -inequality.