costas busch - lsu1 time complexity. costas busch - lsu2 consider a deterministic turing machine...

35
Costas Busch - LSU 1 Time Complexity

Upload: clyde-whitehead

Post on 18-Jan-2018

230 views

Category:

Documents


0 download

DESCRIPTION

Costas Busch - LSU3 For any string the computation of terminates in a finite amount of transitions Accept or Reject Initial state

TRANSCRIPT

Page 1: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 1

Time Complexity

Page 2: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 2

ML

Consider a deterministic Turing Machinewhich decides a language

Page 3: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 3

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

w M

Acceptor Reject w

Initialstate

Page 4: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 4

Acceptor Reject w

Decision Time = #transitions

Initialstate

Page 5: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 5

Consider now all strings of lengthn

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

Page 6: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 6

)(nTM

Max time to accept a string of length n

1 2 3 4 n STRING LENGTH

TIM

E

Page 7: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 7

Time Complexity Class: ))(( nTTIME

All Languages decidable by a deterministic Turing Machinein time

1L 2L

3L

))(( nTO

Page 8: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 8

Example: }0:{1 nbaL n

This can be decided in time)(nO

)(nTIME

}0:{1 nbaL n

Page 9: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 9

)(nTIME

}0:{1 nbaL n

}0,:{ knabaabn

}even is :{ nbn

Other example problems in the same class

}3:{ knbn

Page 10: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 10

)( 2nTIME

}0:{ nba nn

Examples in class:

}},{:{ bawwwR

}},{:{ bawww

Page 11: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 11

)( 3nTIMEExamples in class:

} grammar free-context by generated is :,{2

GwwGL

} and matrices :,,{

321

3213

MMMnnMMML

CYK algorithm

Matrix multiplication

Page 12: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 12

Polynomial time algorithms: )( knTIME

Represents tractable algorithms:for small we can decidethe result fast

k

constant 0k

Page 13: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 13

)( knTIME

)( 1knTIME

)()( 1 kk nTIMEnTIMEIt can be shown:

Page 14: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 14

k

knTIMEP )(

The Time Complexity Class P

•“tractable” problems

•polynomial time algorithmsRepresents:

Page 15: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 15

P

CYK-algorithm

}{ nnba }{ww

Class

Matrix multiplication

}{ ban

Page 16: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 16

Exponential time algorithms: )2( knTIME

Represent intractable algorithms:Some problem instancesmay take centuries to solve

Page 17: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 17

Example: the Hamiltonian Path Problem

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

s t

Page 18: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 18

s t

YES!

Page 19: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 19

)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: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 20

The clique problem

Does there exist a clique of size 5?

Page 21: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 21

The clique problem

Does there exist a clique of size 5?

Page 22: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 22

Example: The Satisfiability Problem

Boolean expressions inConjunctive Normal Form:

ktttt 321

pi xxxxt 321Variables

Question: is the expression satisfiable?

clauses

Page 23: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 23

)()( 3121 xxxx

Satisfiable: 1,1,0 321 xxx

1)()( 3121 xxxx

Example:

Page 24: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 24

2121 )( xxxx

Not satisfiable

Example:

Page 25: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 25

e}satisfiabl is expression :{ wwL

)2( knTIMEL

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

exponential

Page 26: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 26

Non-DeterminismLanguage class: ))(( nTNTIME

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

1L

2L3L

))(( nTOn

Page 27: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 27

0q

iq jq

… … …

… accept

accept

reject

reject

)(nT

(deepest leaf)

depth

All computations of on stringw

nw ||

M

Page 28: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 28

Non-Deterministic Polynomial time algorithms:

)( knNTIMEL

Page 29: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 29

k

knNTIMENP )(

The class NP

Non-Deterministic Polynomial time

Page 30: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 30

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 31: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 31

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 32: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 32

e}satisfiabl is expression :{ wwL

NPL

The satisfiability problem is a - ProblemNP

Page 33: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 33

Observation:

NPP

DeterministicPolynomial

Non-DeterministicPolynomial

Page 34: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 34

Open Problem: ?NPP

WE DO NOT KNOW THE ANSWER

Page 35: Costas Busch - LSU1 Time Complexity. Costas Busch - LSU2 Consider a deterministic Turing Machine which decides a language

Costas Busch - LSU 35

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

WE DO NOT KNOW THE ANSWER

Open Problem: ?NPP