Fall 2004COMP 3351 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
Fall 2004COMP 3352 Example: Algorithm to accept a string : Use a two-tape Turing machine Copy the on the second tape Compare the and
Fall 2004COMP 3353 Copy the on the second tape Compare the and Time needed: Total time:
Fall 2004COMP 3354 For string of length time needed for acceptance:
Fall 2004COMP 3355 Language class: A Deterministic Turing Machine accepts each string of length in time
Fall 2004COMP 3356
Fall 2004COMP 3357 In a similar way we define the class for any time function: Examples:
Fall 2004COMP 3358 Example: The membership problem for context free languages (CYK - algorithm) Polynomial time
Fall 2004COMP 3359 Theorem:
Fall 2004COMP Polynomial time algorithms: Represent tractable algorithms: For small we can compute the result fast
Fall 2004COMP for all The class All tractable problems Polynomial time
Fall 2004COMP CYK-algorithm
Fall 2004COMP Exponential time algorithms: Represent intractable algorithms: Some problem instances may take centuries to solve
Fall 2004COMP Example: the Hamiltonian Problem Question: is there a Hamiltonian path from s to t? s t
Fall 2004COMP s t YES!
Fall 2004COMP Exponential time Intractable problem A solution: search exhaustively all paths L = { : there is a Hamiltonian path in G from s to t}
Fall 2004COMP Example: The Satisfiability Problem Boolean expressions in Conjunctive Normal Form: Variables Question: is expression satisfiable?
Fall 2004COMP Satisfiable: Example:
Fall 2004COMP Not satisfiable Example:
Fall 2004COMP For variables: Algorithm: search exhaustively all the possible binary values of the variables exponential
Fall 2004COMP Non-Determinism Language class: A Non-Deterministic Turing Machine accepts each string of length in time
Fall 2004COMP Example: Non-Deterministic Algorithm to accept a string : Use a two-tape Turing machine Guess the middle of the string and copy on the second tape Compare the two tapes
Fall 2004COMP Time needed: Total time: Use a two-tape Turing machine Guess the middle of the string and copy on the second tape Compare the two tapes
Fall 2004COMP 33524
Fall 2004COMP In a similar way we define the class for any time function: Examples:
Fall 2004COMP Non-Deterministic Polynomial time algorithms:
Fall 2004COMP for all The class Non-Deterministic Polynomial time
Fall 2004COMP Example: The satisfiability problem Non-Deterministic algorithm: Guess an assignment of the variables Check if this is a satisfying assignment
Fall 2004COMP Time for variables: Total time: Guess an assignment of the variables Check if this is a satisfying assignment
Fall 2004COMP The satisfiability problem is an - Problem
Fall 2004COMP Observation: Deterministic Polynomial Non-Deterministic Polynomial
Fall 2004COMP Open Problem: WE DO NOT KNOW THE ANSWER
Fall 2004COMP Example: Does the Satisfiability problem have a polynomial time deterministic algorithm? WE DO NOT KNOW THE ANSWER Open Problem: