NP-complete Problem 2
description
Transcript of NP-complete Problem 2
![Page 1: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/1.jpg)
NP-complete Problem 2Prof. S M Lee
Department of Computer Science
![Page 2: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/2.jpg)
![Page 3: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/3.jpg)
![Page 4: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/4.jpg)
Encodings
An encoding "e" is a mapping from a set S to binary strings
Use encodings to map abstract problems to concrete problems
Example - Shortest Path010100101010010101101100010101001010
![Page 5: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/5.jpg)
![Page 6: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/6.jpg)
![Page 7: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/7.jpg)
![Page 8: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/8.jpg)
![Page 9: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/9.jpg)
![Page 10: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/10.jpg)
![Page 11: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/11.jpg)
![Page 12: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/12.jpg)
![Page 13: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/13.jpg)
![Page 14: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/14.jpg)
![Page 15: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/15.jpg)
![Page 16: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/16.jpg)
Hamiltonian cycle of an undirected graph G= (V, E) is a simple cycle that contains each vertex in V
A hamiltonian graph is a graph that has a hamiltonian cycle.
Let m = |V|, it takes m! operations to determine if G= (V, E) is a hamiltonian graph
If Mary claims a graph is hamiltonian graph and provides the vertices in order on the hamiltonian cycle then we can verify her claim in polynomial time
The potential cycle is called the certificate.
![Page 17: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/17.jpg)
![Page 18: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/18.jpg)
![Page 19: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/19.jpg)
![Page 20: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/20.jpg)
![Page 21: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/21.jpg)
Why Are We Studying NP-complete Problems?
Because we want to know what problems can be solved by computers
![Page 22: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/22.jpg)
![Page 23: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/23.jpg)
![Page 24: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/24.jpg)
Polynomial ReductionsNP-complete problems are known as decision problems. This means that a specific item of input data is accepted and depending on the specific problem, it is required to determine if the instance does have the property, then the answer yes is returned; if not, then the answer no is returned
![Page 25: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/25.jpg)
Polynomial ReductionReduction of a problem P to a problem Q: problem q’s answer for t(x) must be the same as p’s answer for x
T Algorithm for Q
x(an input for p)
T(x)
An input for Q
Yes or No answer
![Page 26: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/26.jpg)
![Page 27: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/27.jpg)
![Page 28: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/28.jpg)
![Page 29: NP-complete Problem 2](https://reader036.fdocuments.net/reader036/viewer/2022062517/56813c30550346895da5ae8d/html5/thumbnails/29.jpg)
A Simple ReductionLet the problem P be: given a sequence of boolean values, does at least one of them have the value trueLet Q be: given a sequence of integers, is the maximum of the integer positive?Let the transformation T be defined by: t(x1,x2,…,xn)=(y1,y2,…,yn) where yi=1 if xi=true, and yi=0 if xi=falseClearly an algorithm to solve Q, when applied to y1,y2,…,yn, solves P for x1,x2,…,xn