NP Completeness and Polynomial Time Algorithms, Slides of Design and Analysis of Algorithms

Np completeness, polynomial time algorithms, and the relationship between p, np, and npc. It covers topics such as np completeness, decision and optimization problems, np-hardness, and reductions in polynomial time. The document also includes examples and proofs of np-completeness for problems like hamiltonian cycle and circuit satisfiability.

Typology: Slides

2011/2012

Uploaded on 08/06/2012

parnavi
parnavi 🇮🇳

4.2

(15)

119 documents

1 / 34

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Lecture No. 44
NP Completeness
Dr. Nazir A. Zafar Advanced Algorithms Analysis and Design
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22

Partial preview of the text

Download NP Completeness and Polynomial Time Algorithms and more Slides Design and Analysis of Algorithms in PDF only on Docsity!

Lecture No. 44

NP Completeness

Polynomial Time Algorithms •^

On any inputs of size n, if worst-case running timeof algorithm is O(n

k^ ), for constant k, then it is called

polynomial time algorithm

-^

Every problem can not be solved in polynomial time

-^

There exists some problems which can not besolved by any computer, in any amount of time, e.g.Turing’s Halting Problem

-^

Such problems are called un-decidable

-^

Some problems can be solved but not in O(n

k^ )

NP Completeness

Decision & Optimization Problems

Decision problems •^

The problems which return yes or no for a given inputand a question regarding the same problem Optimization problems •^

Find a solution with best value, it can be maximum orminimum. There can be more than one solutions for it

-^

Optimization problems can be considered as decisionproblems which are easier to study.

-^

Finding a path between u and v using fewest edges inan un-weighted directed graph is O. P. but does a pathexist from u to v consisting of at most k edges is D. P.?

NP: Nondeterministic Problems

Class NP •^

Problems which are verifiable in polynomial time.

-^

Whether there exists or not any polynomial timealgorithm for solving such problems, we do not know.

-^

Can be solved by nondeterministic polynomial

-^

However if we are given a certificate of a solution, wecould verify that certificate is correct in polynomial time

-^

P = NP?

Example: Hamiltonian Cycle

-^

Given:

a directed graph G = (V, E), determine a

simple cycle that contains each vertex in V, whereeach vertex can only be visited once

-^

Certificate

:

  • Sequence:

v^1

, v

, v 2

, …, v 3

n

  • Generating certificates -^

Verification

:

  1. (v

, vi

i+

)^

E for i = 1, …, n-

  1. (v

, vn^

) 1 

E

It takes polynomial time

hamiltonian not hamiltonian

Reduction in Polynomial Time Algorithm

•^

Given two problems A, B, we say that A is reducible

to B in polynomial time (A

p^

B) if

  1. There exists a function

f

that converts the input

of A to inputs of B in polynomial time

  1. A(x) = YES

B(f(x)) = YES

where x is input for A and f(x) is input for B

NP Complete

-^

A problem A is

NP-complete

if

  1. A

NP

  1. B

p^

A for all B

NP

-^

If A satisfies only property No. 2 then B is

NP-hard

-^

No polynomial time algorithm has been discovered foran

NP-Complete

problem

-^

No one has ever proven that no polynomial timealgorithm can exist for any

NP-Complete

problem

Reduction and NP Completeness

•^

Let A and B are two problems, and also supposethat we are given–^

No polynomial time algorithm exists for problem A

If we have a polynomial reduction f from A to B

•^

Then no polynomial time algorithm exists for B

f^

Problem B

yes no

yes no

Problem A

Boolean Combinational Circuit•^

Boolean combinational elements wired together

-^

Each element takes a set of inputs and produces aset of outputs in constant number, assume binary

-^

Limit the number of outputs to 1

-^

Logic gates: NOT, AND, OR

-^

Satisfying assignment: a true assignment causingthe output to be 1.

-^

A circuit is satisfiable if it has a satisfyingassignment.

Problem Definitions: Circuit Satisfiability

Two Instances: Satisfiable and Un-satisfiable

Proof:•^

Suppose X is

any problem

in NP

•^

Construct polynomial time algorithm

F

that maps

every instance

x

in X to a circuit C =

f

( x

) such that

x

is YES

C

CIRCUIT-SAT (is satisfiable).

•^

Since X

NP, there is a polynomial time algorithm

A

which verifies X.

-^

Suppose the input length is

n

and Let

T

( n

) denote

the worst-case running time.

-^

Let

k

be the constant such that

T

( n

O

( n

k ) and the

length of the certificate is

O

( n

k ).

Lemma 2: CIRCUIT-SAT is NP Hard

•^

Represent computation of

A

as a sequence of

configurations,

c

c

c

, c i

i +

c

T (

n )

,^

each

c

can i^

be broken into various components

-^

c

is mapped to i^

c

i +

by the combinational circuit M

implementing the computer hardware.

-^

It is to be noted that A(x, y) = 1 or 0.

-^

Paste together all T(n) copies of the circuit M. Callthis as, F, the resultant algorithm

-^

Circuit Satisfiability Problem is NP-completePlease see the overall structure in the next slide

•^

Now it can be proved that:1.^

F correctly constructs reduction, i.e., C issatisfiable if and only if there exists a certificate y

, such that

A

( x

,^

y

F runs in polynomial time

(left as an assignment)

-^

Construction of C takes

O

( n

k ) steps, a step takes

polynomial time

-^

F takes polynomial time to construct C from

x

Circuit Satisfiability Problem is NP-complete

Lemma 3 •^

If X is problem such that P‘

p^

X for some P'

NPC,

then X is NP-hard. Moreover, X

NP

X

NPC.

Proof: •^

Since P’ is NPC hence for all P” in NP, we have

P”

p^

P’

•^

And P‘

p^

X

given

•^

By (1) and (2)

-^

P”

p^

P’

p^

X

P”

p^

X

hence X is NP-hard

•^

Now if X

NP

X

NPC

NP-completeness Proof Basis