1 time complexity we use a multitape turing machine we count the number of steps until a string is...

33
1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

Upload: adrian-gordon

Post on 18-Jan-2018

223 views

Category:

Documents


0 download

DESCRIPTION

3 Copy the on the second tape Compare the and Time needed: Total time:

TRANSCRIPT

Page 1: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

1

Time Complexity

•We use a multitape Turing machine

•We count the number of steps until a string is accepted

•We use the O(k) notation

Page 2: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

2

Example: }0:{ nbaL nn

Algorithm to accept a string :w

•Use a two-tape Turing machine

•Copy the on the second tape

•Compare the and

a

a b

Page 3: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

3

|)(|wO•Copy the on the second tape

•Compare the and

a

a b

Time needed:

|)(|wO

Total time: |)(|wO

}0:{ nbaL nn

Page 4: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

4

For string of length

time needed for acceptance:

}0:{ nbaL nn

n

)(nO

Page 5: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

5

Language class: )(nDTIME

A Deterministic Turing Machine accepts each string of length in time

)(nDTIME

1L2L 3L

)(nOn

Page 6: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

6

)(nDTIME

}0:{ nba nn}{ww

Page 7: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

7

In a similar way we define the class

))(( nTDTIME

)(nTfor any time function:

Examples: ),...(),( 32 nDTIMEnDTIME

Page 8: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

8

Example: The membership problem for context free languages

}grammar by generated is :{ GwwL

)( 3nDTIMEL (CYK - algorithm)

Polynomial time

Page 9: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

9

Theorem:

)( knDTIME

)( 1knDTIME

1( ) ( )k kDTIME n DTIME n

Page 10: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

10

Polynomial time algorithms: )( knDTIME

Represent tractable algorithms:For small we can compute theresult fast

k

Page 11: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

11

)( knDTIMEP for all k

The class P

•All tractable problems

•Polynomial time

Page 12: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

12

PCYK-algorithm

}{ nnba

}{ww

Page 13: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

13

Exponential time algorithms: )2( nDTIME

Represent intractable algorithms:Some problem instancesmay take centuries to solve

Page 14: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

14

Example: the Hamiltonian Problem

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

s t

Page 15: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

15

s t

YES!

Page 16: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

16

)2()!( nDTIMEnDTIMEL

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 17: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

17

Example: The Satisfiability Problem

Boolean expressions inConjunctive Normal Form:

ktttt 321

pi xxxxt 321Variables

Question: is expression satisfiable?

Page 18: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

18

)()( 3121 xxxx

Satisfiable: 1,1,0 321 xxx

1)()( 3121 xxxx

Example:

Page 19: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

19

2121 )( xxxx

Not satisfiable

Example:

Page 20: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

20

e}satisfiabl is expression :{ wwL

)2( nDTIMELFor variables: n

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

exponential

Page 21: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

21

Non-DeterminismLanguage class: )(nNTIME

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

)(nNTIME

1L2L 3L

)(nOn

Page 22: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

22

Example: }{wwL

Non-Deterministic Algorithmto accept a string :ww

•Use a two-tape Turing machine

•Guess the middle of the string and copy on the second tape

•Compare the two tapes

w

Page 23: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

23

|)(|wO

Time needed:

|)(|wO

Total time: |)(|wO

}{wwL

•Use a two-tape Turing machine

•Guess the middle of the string and copy on the second tape

•Compare the two tapes

w

Page 24: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

24

)(nNTIME

}{wwL

Page 25: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

25

In a similar way we define the class

))(( nTNTIME

)(nTfor any time function:

Examples: ),...(),( 32 nNTIMEnNTIME

Page 26: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

26

Non-Deterministic Polynomial time algorithms:

)( knNTIMEL

Page 27: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

27

)( knNTIMENP for all k

The class NP

Non-Deterministic Polynomial time

Page 28: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

28

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 29: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

29

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 30: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

30

e}satisfiabl is expression :{ wwL

NPL

The satisfiability problem is an - ProblemNP

Page 31: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

31

Observation:

NPP

DeterministicPolynomial

Non-DeterministicPolynomial

Page 32: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

32

Open Problem: ?NPP

WE DO NOT KNOW THE ANSWER

Page 33: 1 Time Complexity We use a multitape Turing machine We count the number of steps until a string is accepted We use the O(k) notation

33

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

WE DO NOT KNOW THE ANSWER

Open Problem: ?NPP