np-completeness - cpsc 6109 - advanced...
TRANSCRIPT
![Page 1: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/1.jpg)
NP-CompletenessCPSC 6109 - Advanced Algorithms
Dr. Hyrum D. Carroll
April 25, 2019
![Page 2: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/2.jpg)
Complexity Classes
Classes:
I P: Problems that are solvable in polynomial time: O(nk)
I NP: Verifiable in polynomial time(verifiable means we can check the answer)
All problems in P are in NP: P ⊆ NP(because we can more than check an answer, we can solve it inpolynomial time)The open question is if it’s P ⊂ NP
![Page 3: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/3.jpg)
Complexity Classes
Classes:
I P: Problems that are solvable in polynomial time: O(nk)
I NP: Verifiable in polynomial time(verifiable means we can check the answer)
I NP-Complete: as hard as any other problem in NP
All problems in P are in NP: P ⊆ NP(because we can more than check an answer, we can solve it inpolynomial time)The open question is if it’s P ⊂ NP
![Page 4: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/4.jpg)
Complexity Classes (illustrated)
Source: Wikimedia Commons, user: Behnam Esfahbod
![Page 5: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/5.jpg)
Example: Long Simple Paths
I Simple paths are acyclic
I Is determining if a path is simple in P or NP?
I Formally, we would phrase this as, given graph G and verticesu and v and a number k , is there a simple path from u to vwith at most k edges?
I Is this problem in P or NP?
I Given a solution, can we determine if it’s acyclical and has atmost k edges in polynomial time?
I Yes, so this problem is in NP
I Is it in P?
I Can we develop an algorithm that runs in polynomial time?
![Page 6: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/6.jpg)
Example: Long Simple Paths
I Simple paths are acyclic
I Is determining if a path is simple in P or NP?
I Formally, we would phrase this as, given graph G and verticesu and v and a number k , is there a simple path from u to vwith at most k edges?
I Is this problem in P or NP?
I Given a solution, can we determine if it’s acyclical and has atmost k edges in polynomial time?
I Yes, so this problem is in NP
I Is it in P?
I Can we develop an algorithm that runs in polynomial time?
![Page 7: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/7.jpg)
Example: Long Simple Paths
I Simple paths are acyclic
I Is determining if a path is simple in P or NP?
I Formally, we would phrase this as, given graph G and verticesu and v and a number k , is there a simple path from u to vwith at most k edges?
I Is this problem in P or NP?
I Given a solution, can we determine if it’s acyclical and has atmost k edges in polynomial time?
I Yes, so this problem is in NP
I Is it in P?
I Can we develop an algorithm that runs in polynomial time?
![Page 8: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/8.jpg)
Example: Long Simple Paths
I Simple paths are acyclic
I Is determining if a path is simple in P or NP?
I Formally, we would phrase this as, given graph G and verticesu and v and a number k , is there a simple path from u to vwith at most k edges?
I Is this problem in P or NP?
I Given a solution, can we determine if it’s acyclical and has atmost k edges in polynomial time?
I Yes, so this problem is in NP
I Is it in P?
I Can we develop an algorithm that runs in polynomial time?
![Page 9: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/9.jpg)
Example: Long Simple Paths
I Simple paths are acyclic
I Is determining if a path is simple in P or NP?
I Formally, we would phrase this as, given graph G and verticesu and v and a number k , is there a simple path from u to vwith at most k edges?
I Is this problem in P or NP?
I Given a solution, can we determine if it’s acyclical and has atmost k edges in polynomial time?
I Yes, so this problem is in NP
I Is it in P?
I Can we develop an algorithm that runs in polynomial time?
![Page 10: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/10.jpg)
Example: Long Simple Paths
I Simple paths are acyclic
I Is determining if a path is simple in P or NP?
I Formally, we would phrase this as, given graph G and verticesu and v and a number k , is there a simple path from u to vwith at most k edges?
I Is this problem in P or NP?
I Given a solution, can we determine if it’s acyclical and has atmost k edges in polynomial time?
I Yes, so this problem is in NP
I Is it in P?
I Can we develop an algorithm that runs in polynomial time?
![Page 11: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/11.jpg)
Exercise
I Is determining the solution to a linear programming problemin P or NP?
![Page 12: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/12.jpg)
Exercise: Solution
I Is determining the solution to a linear programming problemin P, NP or NP-Complete?
I Cast the question as a yes-no question:
I To determine if in NP, can we, in polynomial-time, determineif a solution is correct?
I Yes
I To determine if in P, can we, in polynomial-time, calculate asolution?
I Yes
I So, in P
I But integer linear programming is NP-Complete :)
![Page 13: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/13.jpg)
Exercise: Solution
I Is determining the solution to a linear programming problemin P, NP or NP-Complete?
I Cast the question as a yes-no question:
I To determine if in NP, can we, in polynomial-time, determineif a solution is correct?
I Yes
I To determine if in P, can we, in polynomial-time, calculate asolution?
I Yes
I So, in P
I But integer linear programming is NP-Complete :)
![Page 14: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/14.jpg)
Exercise: Solution
I Is determining the solution to a linear programming problemin P, NP or NP-Complete?
I Cast the question as a yes-no question:
I To determine if in NP, can we, in polynomial-time, determineif a solution is correct?
I Yes
I To determine if in P, can we, in polynomial-time, calculate asolution?
I Yes
I So, in P
I But integer linear programming is NP-Complete :)
![Page 15: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/15.jpg)
Exercise: Solution
I Is determining the solution to a linear programming problemin P, NP or NP-Complete?
I Cast the question as a yes-no question:
I To determine if in NP, can we, in polynomial-time, determineif a solution is correct?
I Yes
I To determine if in P, can we, in polynomial-time, calculate asolution?
I Yes
I So, in P
I But integer linear programming is NP-Complete :)
![Page 16: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/16.jpg)
Exercise: Solution
I Is determining the solution to a linear programming problemin P, NP or NP-Complete?
I Cast the question as a yes-no question:
I To determine if in NP, can we, in polynomial-time, determineif a solution is correct?
I Yes
I To determine if in P, can we, in polynomial-time, calculate asolution?
I Yes
I So, in P
I But integer linear programming is NP-Complete :)
![Page 17: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/17.jpg)
How knowing about complexity can help you
I If you’re asked to implement a solution to a problem that isNP-Complete, don’t waste your time coming up with an exactsolution, but focus on:
I Approximations (Chapter 35)I HeuristicsI Accepting that an exponential run-time is the best you can doI Determine if you can solve just a subset of the problems
efficiently
![Page 18: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/18.jpg)
Showing a Problem is NP-Complete
I Instead of how easy a problem is, we’re saying, how hard theproblem is
I Instead of proving an efficient algorithm, we showing that, noefficient algorithm is likely to exist
![Page 19: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/19.jpg)
Decision Problems vs. Optimization Problems
I Usually a problem is an optimization problem:
I For each input, what’s the best outputI Example: Shortest Paths (given a graph and weights,
what’s the shortest path between vertices u and v)
I NP-Completeness applies to decision problems (yes / noproblems)
I Usually we can just bound an optimization problem to make ita decision problem
I Example:I Shortest Paths → PathI Given a graph and weights and threshold k, is there a path
between vertices u and v that has at most k edges
![Page 20: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/20.jpg)
Decision Problems vs. Optimization Problems
I Usually a problem is an optimization problem:I For each input, what’s the best output
I Example: Shortest Paths (given a graph and weights,what’s the shortest path between vertices u and v)
I NP-Completeness applies to decision problems (yes / noproblems)
I Usually we can just bound an optimization problem to make ita decision problem
I Example:I Shortest Paths → PathI Given a graph and weights and threshold k, is there a path
between vertices u and v that has at most k edges
![Page 21: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/21.jpg)
Decision Problems vs. Optimization Problems
I Usually a problem is an optimization problem:I For each input, what’s the best outputI Example: Shortest Paths (given a graph and weights,
what’s the shortest path between vertices u and v)
I NP-Completeness applies to decision problems (yes / noproblems)
I Usually we can just bound an optimization problem to make ita decision problem
I Example:I Shortest Paths → PathI Given a graph and weights and threshold k, is there a path
between vertices u and v that has at most k edges
![Page 22: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/22.jpg)
Decision Problems vs. Optimization Problems
I Usually a problem is an optimization problem:I For each input, what’s the best outputI Example: Shortest Paths (given a graph and weights,
what’s the shortest path between vertices u and v)
I NP-Completeness applies to decision problems
(yes / noproblems)
I Usually we can just bound an optimization problem to make ita decision problem
I Example:I Shortest Paths → PathI Given a graph and weights and threshold k, is there a path
between vertices u and v that has at most k edges
![Page 23: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/23.jpg)
Decision Problems vs. Optimization Problems
I Usually a problem is an optimization problem:I For each input, what’s the best outputI Example: Shortest Paths (given a graph and weights,
what’s the shortest path between vertices u and v)
I NP-Completeness applies to decision problems (yes / noproblems)
I Usually we can just bound an optimization problem to make ita decision problem
I Example:I Shortest Paths → PathI Given a graph and weights and threshold k, is there a path
between vertices u and v that has at most k edges
![Page 24: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/24.jpg)
Decision Problems vs. Optimization Problems
I Usually a problem is an optimization problem:I For each input, what’s the best outputI Example: Shortest Paths (given a graph and weights,
what’s the shortest path between vertices u and v)
I NP-Completeness applies to decision problems (yes / noproblems)
I Usually we can just bound an optimization problem to make ita decision problem
I Example:I Shortest Paths → PathI Given a graph and weights and threshold k, is there a path
between vertices u and v that has at most k edges
![Page 25: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/25.jpg)
Decision Problems vs. Optimization Problems
I Usually a problem is an optimization problem:I For each input, what’s the best outputI Example: Shortest Paths (given a graph and weights,
what’s the shortest path between vertices u and v)
I NP-Completeness applies to decision problems (yes / noproblems)
I Usually we can just bound an optimization problem to make ita decision problem
I Example:I Shortest Paths → PathI Given a graph and weights and threshold k, is there a path
between vertices u and v that has at most k edges
![Page 26: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/26.jpg)
Decision Problems vs. Optimization Problems (cont’d)
I Makes problems easier (or at least no harder) than theoptimization problem
I Often, solving the optimization problem will solve the decisionproblem (because it’s a subset of it)
I So, the decision problem version is easier
I If we can prove that the decision problem is hard, then we canprove that the optimization problem is hard
![Page 27: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/27.jpg)
Decision Problems vs. Optimization Problems (cont’d)
I Makes problems easier (or at least no harder) than theoptimization problem
I Often, solving the optimization problem will solve the decisionproblem (because it’s a subset of it)
I So, the decision problem version is easier
I If we can prove that the decision problem is hard, then we canprove that the optimization problem is hard
![Page 28: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/28.jpg)
Decision Problems vs. Optimization Problems (cont’d)
I Makes problems easier (or at least no harder) than theoptimization problem
I Often, solving the optimization problem will solve the decisionproblem (because it’s a subset of it)
I So, the decision problem version is easier
I If we can prove that the decision problem is hard, then we canprove that the optimization problem is hard
![Page 29: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/29.jpg)
Decision Problems vs. Optimization Problems (cont’d)
I Makes problems easier (or at least no harder) than theoptimization problem
I Often, solving the optimization problem will solve the decisionproblem (because it’s a subset of it)
I So, the decision problem version is easier
I If we can prove that the decision problem is hard, then we canprove that the optimization problem is hard
![Page 30: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/30.jpg)
Reductions
I Almost every NP-Complete proof makes a reduction of oneproblem to another
![Page 31: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/31.jpg)
Polynomial-Time Reductions
I Instance: 1 particular set of inputs
I We want to solve a decision problem A in polynomial-time
I We have a known polynomial-time solution to decisionproblem B
I We have a polynomial-time mapping for every instant of A(α) to an instance of B (β) such that the answer to α is yes ifand only if the answer to β is yes
Figure 34.1 from Introduction to Algorithms 3rd Edition
![Page 32: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/32.jpg)
Polynomial-Time Reductions
I Instance: 1 particular set of inputs
I We want to solve a decision problem A in polynomial-time
I We have a known polynomial-time solution to decisionproblem B
I We have a polynomial-time mapping for every instant of A(α) to an instance of B (β) such that the answer to α is yes ifand only if the answer to β is yes
Figure 34.1 from Introduction to Algorithms 3rd Edition
![Page 33: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/33.jpg)
Polynomial-Time Reductions
I Instance: 1 particular set of inputs
I We want to solve a decision problem A in polynomial-time
I We have a known polynomial-time solution to decisionproblem B
I We have a polynomial-time mapping for every instant of A(α) to an instance of B (β) such that the answer to α is yes ifand only if the answer to β is yes
Figure 34.1 from Introduction to Algorithms 3rd Edition
![Page 34: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/34.jpg)
Polynomial-Time Reductions
I Instance: 1 particular set of inputs
I We want to solve a decision problem A in polynomial-time
I We have a known polynomial-time solution to decisionproblem B
I We have a polynomial-time mapping for every instant of A(α) to an instance of B (β) such that the answer to α is yes ifand only if the answer to β is yes
Figure 34.1 from Introduction to Algorithms 3rd Edition
![Page 35: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/35.jpg)
Polynomial-Time Reductions
I Instance: 1 particular set of inputs
I We want to solve a decision problem A in polynomial-time
I We have a known polynomial-time solution to decisionproblem B
I We have a polynomial-time mapping for every instant of A(α) to an instance of B (β) such that the answer to α is yes ifand only if the answer to β is yes
Figure 34.1 from Introduction to Algorithms 3rd Edition
![Page 36: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/36.jpg)
Polynomial-Time Reductions (Pseudocode)
Boolean B( β ); // known solution
Boolean A( α ){return B( transformArgs( α ) );
}I If B() and transformArgs() each take polynomial-time,
then A() takes polynomial-time
I We “reduce” problem A to solving problem B
I We use the easiness of B to prove the easiness of A
![Page 37: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/37.jpg)
Polynomial-Time Reductions (Pseudocode)
Boolean B( β ); // known solution
Boolean A( α ){return B( transformArgs( α ) );
}I If B() and transformArgs() each take polynomial-time,
then A() takes polynomial-time
I We “reduce” problem A to solving problem B
I We use the easiness of B to prove the easiness of A
![Page 38: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/38.jpg)
Polynomial-Time Reductions (Pseudocode)
Boolean B( β ); // known solution
Boolean A( α ){return B( transformArgs( α ) );
}I If B() and transformArgs() each take polynomial-time,
then A() takes polynomial-time
I We “reduce” problem A to solving problem B
I We use the easiness of B to prove the easiness of A
![Page 39: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/39.jpg)
Polynomial-Time Reductions In Reverse
I For NP-Complete, we want to show at least how hard aproblem is
I Assume we have:
1. A problem A that does not have a polynomial-time solution2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that nopolynomial-time solution can exist for B:
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions)
I That’s not possible, so B cannot have a polynomial-timesolution
![Page 40: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/40.jpg)
Polynomial-Time Reductions In Reverse
I For NP-Complete, we want to show at least how hard aproblem is
I Assume we have:
1. A problem A that does not have a polynomial-time solution
2. A polynomial-time mapping of every instance of A to aninstance of B
I Using proof by contradiction, we can show that nopolynomial-time solution can exist for B:
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions)
I That’s not possible, so B cannot have a polynomial-timesolution
![Page 41: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/41.jpg)
Polynomial-Time Reductions In Reverse
I For NP-Complete, we want to show at least how hard aproblem is
I Assume we have:
1. A problem A that does not have a polynomial-time solution2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that nopolynomial-time solution can exist for B:
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions)
I That’s not possible, so B cannot have a polynomial-timesolution
![Page 42: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/42.jpg)
Polynomial-Time Reductions In Reverse
I For NP-Complete, we want to show at least how hard aproblem is
I Assume we have:
1. A problem A that does not have a polynomial-time solution2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that nopolynomial-time solution can exist for B:
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions)
I That’s not possible, so B cannot have a polynomial-timesolution
![Page 43: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/43.jpg)
Polynomial-Time Reductions In Reverse
I For NP-Complete, we want to show at least how hard aproblem is
I Assume we have:
1. A problem A that does not have a polynomial-time solution2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that nopolynomial-time solution can exist for B:
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions)
I That’s not possible, so B cannot have a polynomial-timesolution
![Page 44: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/44.jpg)
Polynomial-Time Reductions In Reverse
I For NP-Complete, we want to show at least how hard aproblem is
I Assume we have:
1. A problem A that does not have a polynomial-time solution2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that nopolynomial-time solution can exist for B:
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions)
I That’s not possible, so B cannot have a polynomial-timesolution
![Page 45: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/45.jpg)
Polynomial-Time Reductions In Reverse → NP-Complete
For NP-Completeness:
I Use polynomial-time reductions in reverse to show thatproblem B is NP-Complete (if A is NP-Complete)
I Assume we have:
1. A problem A that is NP-Complete2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that B isNP-Complete.
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions).
I That’s not possible, so B cannot have a polynomial-timesolution.
![Page 46: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/46.jpg)
Polynomial-Time Reductions In Reverse → NP-Complete
For NP-Completeness:
I Use polynomial-time reductions in reverse to show thatproblem B is NP-Complete (if A is NP-Complete)
I Assume we have:
1. A problem A that is NP-Complete2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that B isNP-Complete.
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions).
I That’s not possible, so B cannot have a polynomial-timesolution.
![Page 47: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/47.jpg)
Polynomial-Time Reductions In Reverse → NP-Complete
For NP-Completeness:
I Use polynomial-time reductions in reverse to show thatproblem B is NP-Complete (if A is NP-Complete)
I Assume we have:
1. A problem A that is NP-Complete2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that B isNP-Complete.
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions).
I That’s not possible, so B cannot have a polynomial-timesolution.
![Page 48: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/48.jpg)
Polynomial-Time Reductions In Reverse → NP-Complete
For NP-Completeness:
I Use polynomial-time reductions in reverse to show thatproblem B is NP-Complete (if A is NP-Complete)
I Assume we have:
1. A problem A that is NP-Complete
2. A polynomial-time mapping of every instance of A to aninstance of B
I Using proof by contradiction, we can show that B isNP-Complete.
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions).
I That’s not possible, so B cannot have a polynomial-timesolution.
![Page 49: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/49.jpg)
Polynomial-Time Reductions In Reverse → NP-Complete
For NP-Completeness:
I Use polynomial-time reductions in reverse to show thatproblem B is NP-Complete (if A is NP-Complete)
I Assume we have:
1. A problem A that is NP-Complete2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that B isNP-Complete.
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions).
I That’s not possible, so B cannot have a polynomial-timesolution.
![Page 50: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/50.jpg)
Polynomial-Time Reductions In Reverse → NP-Complete
For NP-Completeness:
I Use polynomial-time reductions in reverse to show thatproblem B is NP-Complete (if A is NP-Complete)
I Assume we have:
1. A problem A that is NP-Complete2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that B isNP-Complete.
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions).
I That’s not possible, so B cannot have a polynomial-timesolution.
![Page 51: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/51.jpg)
Polynomial-Time Reductions In Reverse → NP-Complete
For NP-Completeness:
I Use polynomial-time reductions in reverse to show thatproblem B is NP-Complete (if A is NP-Complete)
I Assume we have:
1. A problem A that is NP-Complete2. A polynomial-time mapping of every instance of A to an
instance of B
I Using proof by contradiction, we can show that B isNP-Complete.
I Assume that B has a polynomial-time solution. Then, we cansolve all instances of A using B (using polynomial-timereductions).
I That’s not possible, so B cannot have a polynomial-timesolution.
![Page 52: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/52.jpg)
Exercise: One NP-Complete Problem
I Choose one of Karp’s 21 NP-Complete problems
I Describe your algorithm
I Describe how we know it’s NP-Complete
![Page 53: NP-Completeness - CPSC 6109 - Advanced Algorithmscsc.columbusstate.edu/carroll/6109/npCompleteness/... · I NP-Completeness applies to decision problems (yes / no problems) I Usually](https://reader033.vdocuments.us/reader033/viewer/2022052104/603f13f87e18a96c4c4b943c/html5/thumbnails/53.jpg)
Exercise: Heirarchy of Karp’s 21 NP-Complete Problems
I Draw a heirarchy (showing which problem was reduce to aknown NP-complete problem) for each one of Karp’s 21NP-complete problems