np-complete problem 2

29
NP-complete Problem 2 Prof. S M Lee Department of Computer Science

Upload: carson

Post on 06-Jan-2016

43 views

Category:

Documents


2 download

DESCRIPTION

Lecture 25. NP-complete Problem 2. Prof. S M Lee Department of Computer Science. 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 Path 010100101010010101101100010101001010. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: NP-complete Problem 2

NP-complete Problem 2Prof. S M Lee

Department of Computer Science

Page 2: NP-complete Problem 2
Page 3: NP-complete Problem 2
Page 4: NP-complete Problem 2

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
Page 6: NP-complete Problem 2
Page 7: NP-complete Problem 2
Page 8: NP-complete Problem 2
Page 9: NP-complete Problem 2
Page 10: NP-complete Problem 2
Page 11: NP-complete Problem 2
Page 12: NP-complete Problem 2
Page 13: NP-complete Problem 2
Page 14: NP-complete Problem 2
Page 15: NP-complete Problem 2
Page 16: NP-complete Problem 2

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
Page 18: NP-complete Problem 2
Page 19: NP-complete Problem 2
Page 20: NP-complete Problem 2
Page 21: NP-complete Problem 2

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
Page 23: NP-complete Problem 2
Page 24: NP-complete Problem 2

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

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
Page 27: NP-complete Problem 2
Page 28: NP-complete Problem 2
Page 29: NP-complete Problem 2

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