/
NP-Complete Problems NP-Complete Problems

NP-Complete Problems - PowerPoint Presentation

faustina-dinatale
faustina-dinatale . @faustina-dinatale
Follow
399 views
Uploaded On 2017-05-30

NP-Complete Problems - PPT Presentation

Running Time vs Input Size Concern with problems whose complexity may be described by exponential functions Tractable problems vs intractable problems Decision Problems Optimization problems ID: 554221

decision problem problems complete problem decision complete problems clique vertices polynomial input algorithm polynomially boolean reduction bounded objects question

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "NP-Complete Problems" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

NP-Complete ProblemsSlide2

Running Time v.s. Input Size

Concern with problems whose complexity may be described by

exponential functions.

Tractable problems v.s. intractable problemsSlide3

Decision Problems

Optimization problems

can be formulated as decision problems.

A decision problem is a question that has two possible answers,

yes and no.

A problem instance is the combination of the problem and a specific input.The instance description part defines the information expected in the input.The question part state the actual yes-or-no question; the question contains variables defined in the instance description.

A precise statement of the input is important

Instance

: an undirected graph G = (V, E). Question: Does G contain a clique of k vertices? (A clique is a complete subgraph: every pair of vertices in the subgraph has an edge between them)Instance: an undirected graph G = (V, E) and an integer k. Question: Does G contain a clique of k vertices?Slide4

Example Decision Problems

Bin packing

Suppose we have an unlimted number of bins each of capacity one, and n objects with sizes s

1, …, s

n where 0 ≤ si ≤ 1.Optimization problem

: Determine the smallest number of bins into which the objects can be packed.Decision problem: Given, in addition to the inputs described, an integer k, do the objects fit in k bins?Knapsack Suppose we have a knapsack of capacity C (a positive integer) and n objects with sizes s1, …, sn

and “profits” p

1

, …, pn.Optimization problem: Find the largest total profit of any subset of the objects that fits in the knapsack.Decision problem: Given k, is there a subset of the objects that fits in the knapsack and has total profit at least k?Slide5

Example Decision Problems

Subset sum

The input is a positive integer C and n objects whose sizes are positive integers s

1, …, sn

Optimization problem: Among subsets of the objects with sum at most C, what is the largest subset sum?

Decision problem: Is there a subset of the objects whose sizes add up to exactly C?Satisfiability Given a Boolean expression S involving only Boolean variables and values in conjunctive normal form (CNF)Decision problem: Can we find an assignment of Boolean values to the variables such that S is evaluated to the value of 1?

Some concepts

A

Boolean variable is a variable that may be assigned the value 1 or 0.A literal is a Boolean variable or the negation of a Boolean variable.A clause is a sequence of literals separated by the Boolean or operator ().A Boolean formula is in conjunctive normal form

(CNF) if it consists of a sequence of clauses separated by the

Boolean and

operator ().Slide6

The Class P

Polynomially bounded

An algorithm is said to be

polynomially bounded if its worst-case complexity is bounded by a polynomial function of the input size.

A problem is said to be polynomially bounded if there is a polynomially bounded algorithm for it.The class P

P is the class of decision problems that are polynomially bounded.The problems in P may not be “tractable” in practice, but those not in P are intractable.Slide7

The Class NP

Nondeterministic algorithm

A

nondeterministic algorithm has two phases and output step:

The nondeterministic “guessing” phase: guess a “proposed solution” s (called certificate)

The deterministic “verifying” phase: A deterministic (i.e., ordinary) subroutine begins execution. In addition to the decision problems’ input, the subroutine may use s. Eventually it returns a value true or false  or it may get in an infinite loop and never halt. (Think of the verifying phase as checking s

to see if it is a solution for the decision problem’s input, i.e., if it justifies a yes answer for the decision problem’s input

.)

The output step. If the verifying phase returned true, the algorithm outputs yes. Otherwise, there is no output.A nondeterministic algorithm is said to be polynomially bounded if there is a polynomial p such that for each input of size n for which the answer is yes, there is some execution of the algorithm that produces a yes

output in at most p(n) time.

NP

is the class of decision problems for which there is a polynomially bounded nondeterministic algorithm.Slide8

The Class NP

Nondeterministic graph coloring

Given an undirected graph G = (V, E) with n vertices and an integer k, is G colorable with k colors such that each edge connecting two vertices with different colors?

Guess a “proposed solution”

s The deterministic “verifying” phaseCheck that each vertex is assigned a color

Totally there are at most k different colorsScan the list of edges in the graph and check that the two vertices incident upon one edge have different colors.The output step. If the verifying phase returned true, the algorithm outputs yes. Otherwise, there is no output.

1

4

2

5

3Slide9

The Class NP

Nondeterministic vertex covering

Given an undirected graph G = (V, E) with n vertices and an integer k, is there a subset S of k vertices in G such that for each edge (u, v), either uS or vS?

Generate all subsets of k vertices of G;

Non-deterministically select a subset S of k vertices from G;For every vertex v in G, check whether v is adjacent to someone in S.

P  NPNP = P ? P  NP

P

NPSlide10

NP-Hard/NP-Complete

NP-complete problems are most “die-hard” problems in the class of NP.

Polynomial reductions

Let T be a function from the input set for a decision problem P into the input set for a decision problem Q. T is a

polynomial reduction from P to Q if all of the following hold:T can be computed in polynomially bounded time.For every instance x of P, the answer to x is

yes if and only if the answer to instance T(x) of Q is yes.Problem P is polynomially reducible to Q if there exists a polynomial reduction from P to Q.

P

Q

Polynomial reduction (encoding)

decodingSlide11

NP-Hard/NP-Complete

Polynomial reductions are transitive.

NP-hard

: A problem X is called an NP-hard problem if every problem in NP is polynomially reducible to X.

A

B

encoding

decoding

C

encoding

decoding

encoding

decoding

X

NPSlide12

NP-Hard/NP-Complete

NP-Complete

: A problem X is NP-complete if the followings are true:

X is in NP (there is a non-deterministic polynomial time algorithm for X), andX is NP-hard (for every problem in NP, there is a polynomial reduction to X).

Cook’s

theorem (1971): The first NP-complete Problem The

satisfiability

problem (SAT) is NP-complete

X

NPSlide13

Proving NP-Completeness

Steps for proving a problem X is NP-complete.

Problem X is in NP

Find an NP-complete problem Y, and a polynomial reduction from Y to X

A good reduction R must doMaps any instance of Y to some instances of X

The answer to Y is yes if and only if the answer to X is yes.R should take polynomial time deterministically.

Y

X

RSlide14

Examples

The clique problem

Instance

: an undirected graph G = (V, E) and an integer k.

Question: Does G contain a clique of k vertices (A clique is a complete subgraph: every pair of vertices in the subgraph has an edge between them)?

Show the clique problem is NP-completeProofFind a non-deterministic polynomial algorithm for the clique problemFind a problem which is NP-complete (SAT), and a polynomial reduction.SAT: Instance: Given a CNF F = C

1

C2…Ck, where Ci = xi1xi2…xiki

Question

: Is F satisfiable?

The reduction

: Create a graph G = (V, E), V = {v

ij

| x

ij

 C

i

}

The vertices from the same clause are not connected by edges

v

ij

and v

lk

are not connected if

Connect everything else

The reduction must make sense:

There is a k-clique in G if and only if SAT is satisfiable

.Slide15

Examples

Proof (cont.)

The reduction must make sense:

There is a k-clique in G if and only if SAT is satisfiable

.“” If there is a k-clique in G, then F is satisfiable.For each vertex vij

in the k-clique, let its corresponding literal xij or be 1 (true). And set all other boolean variable to be 0 (false).No conflict assignmentFor each clause, there are at most one literal in the k-cliqueThere are k clauses in F “” If F is satisfiable, then there is a k-clique.

For each clause C

i

= xi1xi2…xiki, if xij = 1, then vij is taken.vij corresponding x

ij

is taken, v

lk

corresponding

will not

be taken, where