Title: Time Complexity
1Time Complexity Slides based on RPI CSCI
2400 Thanks to Costas Busch
2Question so far
Computable? Yes or no?
This lecture Computable in reasonable
time? Goal Low time complexity
3Consider a decidable (recursive) language
which is decided by a Turing Machine
For any string the computation
of terminates (in an accept of reject state) in a
finite amount of transitions
Accept or Reject
Time transitions followed
4Max time to accept a string of length
5Language class
Languages for which there is a deterministic
Turing Machine that decides each string of the
language within time
6Language classes for 1) an 2) anbn 3)
membership problem for context free languages ?
7Examples
8Big-oh notation
9Example The membership problem
for context free languages
(CYK - algorithm)
Polynomial time
10Theorem
11Polynomial time algorithms
For every constant
Represent tractable algorithms
For small we can compute the result fast
12Example word w, !w!10
13The class
for all
14CYK-algorithm
15Exponential time algorithms
Represent intractable algorithms
Some problem instances may take centuries to
solve Making computers faster doesn't help. Why?
16Example
17Example the Hamiltonian Path Problem
s
t
Question is there a Hamiltonian path
from s to t?
18s
t
YES!
19Algorithm?
20A solution search exhaustively all paths
L ltG,s,tgt there is a Hamiltonian path
in G from s to t
Exponential time
Intractable problem
21The clique problem
22The clique problem Exponential
23Example The Satisfiability Problem
Boolean expressions in Conjunctive Normal Form
Variables
Question is the expression satisfiable?
24(not x1 or x2) and (x1 or x3) (x1 or x2) and
(not x1) and (not x2)
25Example
Satisfiable
26Example
Not satisfiable
27exponential
Algorithm search exhaustively all the
possible binary values of the variables
28Non-Determinism
Language class
A Non-Deterministic Turing Machine accepts each
string of length in time
29Example
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
30Time 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
31(No Transcript)
32In a similar way we define the class
for any time function
Examples
33Non-Deterministic Polynomial time algorithms
34The class
for all
Non-Deterministic Polynomial time
35The satisfiability problem
Example
Non-Deterministic algorithm
- Guess an assignment of the variables
- Check if this is a satisfying assignment
36Time for variables (or length of
expression?)
- Guess an assignment of the variables
- Check if this is a satisfying assignment
Total time
37The satisfiability problem is an - Problem
38Observation
Deterministic Polynomial
Non-Deterministic Polynomial
39Open Problem
WE DO NOT KNOW THE ANSWER
40Open Problem
Example Does the Satisfiability problem
have a polynomial time
deterministic algorithm?
WE DO NOT KNOW THE ANSWER