Docsity

Time & Complexity Classes: Deterministic & Non-Deterministic Turing Machines - Prof. Petro, Study notes of Computer Science

Partial preview of the text

Download Time & Complexity Classes: Deterministic & Non-Deterministic Turing Machines - Prof. Petro and more Study notes Computer Science in PDF only on Docsity!

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

Example: (^) L { a b : n  0 } n n Algorithm to accept a string w :

  • Use a two-tape Turing machine
  • Copy the on the second tape
  • Compare the and a a (^) b

For string of length time needed for acceptance: L { a b : n  0 } n n n O ( n )

Language class: DTIME ( n ) A Deterministic Turing Machine accepts each string of length in time DTIME ( n ) 1

L

2

L

3

L

O ( n ) n

In a similar way we define the class DTIME ( T ( n )) for any time function: T ( n^ ) Examples: (^ ), ( ),... 2 3 DTIME n DTIME n

Example: The membership problem for context free languages L { w : w is generated by grammar G } ( ) 3 LDTIME n (CYK - algorithm) Polynomial time

Polynomial time algorithms: ( ) k DTIME n Represent tractable algorithms: For small we can compute the result fast k

k P  DTIME n for all k

The class P

  • All tractable problems
  • Polynomial time

Exponential time algorithms: ( 2 ) n DTIME Represent intractable algorithms: Some problem instances may take centuries to solve

14 Example: the Hamiltonian Problem Question: is there a Hamiltonian path from s to t? s t

n LDTIME nDTIME 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}

Example: The Satisfiability Problem Boolean expressions in Conjunctive Normal Form: k ttt   t 1 2 3 i p txxx   x 1 2 3 Variables Question: is expression satisfiable?

1 2 1 2 ( xx )  xx Not satisfiable Example:

L { w :expression w is satisfiabl e} ( 2 ) n For n variables: LDTIME Algorithm: search exhaustively all the possible binary values of the variables exponential