Title: Time%20Complexity
1Time Complexity
- We use a multitape Turing machine
- We count the number of steps until
- a string is accepted
- We use the O(k) notation
2Example
Algorithm to accept a string
- Use a two-tape Turing machine
- Copy the on the second tape
- Compare the and
3Time needed
- Copy the on the second tape
- Compare the and
Total time
4For string of length time needed for acceptance
5Language class
A Deterministic Turing Machine accepts each
string of length in time
6(No Transcript)
7In a similar way we define the class
for any time function
Examples
8Example The membership problem
for context free languages
(CYK - algorithm)
Polynomial time
9Theorem
10Polynomial time algorithms
Represent tractable algorithms
For small we can compute the result fast
11The class
for all
12CYK-algorithm
13Exponential time algorithms
Represent intractable algorithms
Some problem instances may take centuries to solve
14Example the Hamiltonian Problem
s
t
Question is there a Hamiltonian path
from s to t?
15s
t
YES!
16A solution search exhaustively all paths
L ltG,s,tgt there is a Hamiltonian path
in G from s to t
Exponential time
Intractable problem
17Example The Satisfiability Problem
Boolean expressions in Conjunctive Normal Form
Variables
Question is expression satisfiable?
18Example
Satisfiable
19Example
Not satisfiable
20For variables
exponential
Algorithm search exhaustively all the
possible binary values of the variables
21Non-Determinism
Language class
A Non-Deterministic Turing Machine accepts each
string of length in time
22Example
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
23Time needed
- Use a two-tape Turing machine
- Guess the middle of the string
- and copy on the second tape
- Compare the two tapes
Total time
24(No Transcript)
25In a similar way we define the class
for any time function
Examples
26Non-Deterministic Polynomial time algorithms
27The class
for all
Non-Deterministic Polynomial time
28The satisfiability problem
Example
Non-Deterministic algorithm
- Guess an assignment of the variables
- Check if this is a satisfying assignment
29Time for variables
- Guess an assignment of the variables
- Check if this is a satisfying assignment
Total time
30The satisfiability problem is an - Problem
31Observation
Deterministic Polynomial
Non-Deterministic Polynomial
32Open Problem
WE DO NOT KNOW THE ANSWER
33Open Problem
Example Does the Satisfiability problem
have a polynomial time
deterministic algorithm?
WE DO NOT KNOW THE ANSWER