Professional Documents
Culture Documents
a
•Compare the and b
2
n n
L {a b : n 0}
Time needed:
Total time: O (| w |)
3
n n
L {a b : n 0}
4
Language class: DTIME (n)
DTIME (n)
L1 L3
L2
n n
{a b : n 0}
{ww}
6
In a similar way we define the class
DTIME (T (n))
2 3
Examples: DTIME (n ), DTIME (n ),...
7
Example: The membership problem
for context free languages
L {w : w is generated by grammar G}
3
L DTIME (n ) (CYK - algorithm)
Polynomial time
8
k 1 k
Theorem: DTIME (n ) DTIME (n )
k 1
DTIME (n )
k
DTIME (n )
9
k
Polynomial time algorithms: DTIME (n )
10
The class P
k
P DTIME (n ) for all k
•Polynomial time
{ww}
12
n
Exponential time algorithms: DTIME (2 )
13
Example: the Hamiltonian Problem
s t
YES!
15
A solution: search exhaustively all paths
n
L DTIME (n!) DTIME (2 )
Exponential time
Intractable problem
16
Example: The Satisfiability Problem
Boolean expressions in
Conjunctive Normal Form:
t1 t2 t3 tk
ti x1 x2 x3 x p
Variables
Satisfiable: x1 0, x2 1, x3 1
( x1 x2 ) ( x1 x3 ) 1
18
Example: ( x1 x2 ) x1 x2
Not satisfiable
19
L {w : expression w is satisfiable}
n
For n variables: L DTIME (2 )
exponential
Algorithm:
search exhaustively all the possible
binary values of the variables
20
Non-Determinism
Language class: NTIME (n)
NTIME (n)
L1 L3
L2
Non-Deterministic Algorithm
to accept a string ww :
O (| w |)
•Compare the two tapes
Total time: O (| w |)
23
NTIME (n)
L {ww}
24
In a similar way we define the class
NTIME (T (n))
2 3
Examples: NTIME (n ), NTIME (n ),...
25
Non-Deterministic Polynomial time algorithms:
k
L NTIME ( n )
26
The class NP
k
NP NTIME (n ) for all k
27
Example: The satisfiability problem
L {w : expression w is satisfiable}
Non-Deterministic algorithm:
•Guess an assignment of the variables
28
L {w : expression w is satisfiable}
L NP
30
Observation:
P NP
Deterministic Non-Deterministic
Polynomial Polynomial
31
Open Problem: P NP ?
32
Open Problem: P NP ?