time complexity p vs np. consider a deterministic turing machine which decides a language

36
Time Complexity P vs NP

Upload: patricia-curd

Post on 01-Apr-2015

216 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Time ComplexityP vs NP

Page 2: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

ML

Consider a deterministic Turing Machinewhich decides a language

Page 3: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

For any string the computation ofterminates in a finite amount of transitions

w M

Acceptor Reject w

Initialstate

Page 4: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Acceptor Reject w

Decision Time = #transitions

Initialstate

Page 5: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Consider now all strings of lengthn

)(nTM = maximum time required to decide any string of length n

Page 6: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

)(nTM

Max time to accept a string of length n

1 2 3 4 n STRING LENGTH

TIM

E

Page 7: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Time Complexity Class: ))(( nTTIME

All Languages decidable by a deterministic Turing Machinein time

1L 2L

3L

))(( nTO

Page 8: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Example: }0:{1 nbaL n

This can be decided in time)(nO

)(nTIME

}0:{1 nbaL n

Page 9: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

)(nTIME

}0:{1 nbaL n

}0,:{ knabaabn

}even is :{ nbn

Other example problems in the same class

}3:{ knbn

Page 10: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

)( 2nTIME

}0:{ nba nn

Examples in class:

}},{:{ bawwwR

}},{:{ bawww

Page 11: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

)( 3nTIMEExamples in class:

} grammar free-context

by generated is :,{2

G

wwGL

} and

matrices :,,{

321

3213

MMM

nnMMML

CYK algorithm

Matrix multiplication

Page 12: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Polynomial time algorithms: )( knTIME

Represents tractable algorithms:

for small we can decidethe result fast

k

constant 0k

Page 13: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

)( knTIME

)( 1knTIME

)()( 1 kk nTIMEnTIME It can be shown:

Page 14: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

0

)(

k

knTIMEP

The Time Complexity Class P

•“tractable” problems

•polynomial time algorithms

Represents:

Page 15: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

P

CYK-algorithm

}{ nnba }{ww

Class

Matrix multiplication

}{ ban

Page 16: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Exponential time algorithms: )2(knTIME

Represent intractable algorithms:

Some problem instancesmay take centuries to solve

Page 17: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Example: the Hamiltonian Path Problem

Question: is there a Hamiltonian path from s to t?

s t

Page 18: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

s t

YES!

Page 19: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

)2()!(knTIMEnTIMEL

Exponential time

Intractable problem

A solution: search exhaustively all paths

L = {<G,s,t>: there is a Hamiltonian path in G from s to t}

Page 20: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

The clique problem

Does there exist a clique of size 5?

Page 21: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

The clique problem

Does there exist a clique of size 5?

Page 22: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Example: The Satisfiability Problem

Boolean expressions inConjunctive Normal Form:

ktttt 321

pi xxxxt 321

Variables

Question: is the expression satisfiable?

clauses

Page 23: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

)()( 3121 xxxx

Satisfiable: 1,1,0 321 xxx

1)()( 3121 xxxx

Example:

Page 24: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

2121 )( xxxx

Not satisfiable

Example:

Page 25: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

e}satisfiabl is expression :{ wwL

)2(knTIMEL

Algorithm: search exhaustively all the possible binary values of the variables

exponential

Page 26: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Non-Determinism

Language class: ))(( nTNTIME

A Non-Deterministic Turing Machine decides each string of length in time

1L

2L3L

))(( nTO

n

Page 27: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Non-Deterministic Polynomial time algorithms:

)( knNTIMEL

Page 28: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

0

)(

k

knNTIMENP

The class NP

Non-Deterministic Polynomial time

Page 29: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Example: The satisfiability problem

Non-Deterministic algorithm:

•Guess an assignment of the variables

e}satisfiabl is expression :{ wwL

•Check if this is a satisfying assignment

Page 30: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Time for variables: n

)(nO

e}satisfiabl is expression :{ wwL

Total time:

•Guess an assignment of the variables

•Check if this is a satisfying assignment )(nO

)(nO

Page 31: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

e}satisfiabl is expression :{ wwL

NPL

The satisfiability problem is an - ProblemNP

Page 32: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Observation:

NPP

DeterministicPolynomial

Non-DeterministicPolynomial

Page 33: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Open Problem: ?NPP

WE DO NOT KNOW THE ANSWER

Page 34: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Example: Does the Satisfiability problem have a polynomial time deterministic algorithm?

WE DO NOT KNOW THE ANSWER

Open Problem: ?NPP

Page 35: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

P versus NPP versus NP (polynomial versus

nondeterministic polynomial) refers to a theoretical question presented in 1971 by Leonid Levin and Stephen Cook, concerning mathematical problems that are easy to solve (P type) as opposed to problems that are difficult to solve (NP type).

Page 36: Time Complexity P vs NP. Consider a deterministic Turing Machine which decides a language

Any P type problem can be solved in "polynomial time.“ A P type problem is a polynomial in the number of bits

that it takes to describe the instance of the problem at hand. An example of a P type problem is finding the way from point A to point B on a map. An NP type problem requires vastly more time to solve than it takes to describe the problem.

An example of an NP type problem is breaking a 128-bit digital cipher.

The P versus NP question is important in communications, because it may ultimately determine the effectiveness (or ineffectiveness) of digital encryption methods.