View
230
Download
0
Category
Preview:
DESCRIPTION
Costas Busch - LSU3 For any string the computation of terminates in a finite amount of transitions Accept or Reject Initial state
Citation preview
Costas Busch - LSU 1
Time Complexity
Costas Busch - LSU 2
ML
Consider a deterministic Turing Machinewhich decides a language
Costas Busch - LSU 3
For any string the computation ofterminates in a finite amount of transitions
w M
Acceptor Reject w
Initialstate
Costas Busch - LSU 4
Acceptor Reject w
Decision Time = #transitions
Initialstate
Costas Busch - LSU 5
Consider now all strings of lengthn
)(nTM = maximum time required to decide any string of length n
Costas Busch - LSU 6
)(nTM
Max time to accept a string of length n
1 2 3 4 n STRING LENGTH
TIM
E
Costas Busch - LSU 7
Time Complexity Class: ))(( nTTIME
All Languages decidable by a deterministic Turing Machinein time
1L 2L
3L
))(( nTO
Costas Busch - LSU 8
Example: }0:{1 nbaL n
This can be decided in time)(nO
)(nTIME
}0:{1 nbaL n
Costas Busch - LSU 9
)(nTIME
}0:{1 nbaL n
}0,:{ knabaabn
}even is :{ nbn
Other example problems in the same class
}3:{ knbn
Costas Busch - LSU 10
)( 2nTIME
}0:{ nba nn
Examples in class:
}},{:{ bawwwR
}},{:{ bawww
Costas Busch - LSU 11
)( 3nTIMEExamples in class:
} grammar free-context by generated is :,{2
GwwGL
} and matrices :,,{
321
3213
MMMnnMMML
CYK algorithm
Matrix multiplication
Costas Busch - LSU 12
Polynomial time algorithms: )( knTIME
Represents tractable algorithms:for small we can decidethe result fast
k
constant 0k
Costas Busch - LSU 13
)( knTIME
)( 1knTIME
)()( 1 kk nTIMEnTIMEIt can be shown:
Costas Busch - LSU 14
k
knTIMEP )(
The Time Complexity Class P
•“tractable” problems
•polynomial time algorithmsRepresents:
Costas Busch - LSU 15
P
CYK-algorithm
}{ nnba }{ww
Class
Matrix multiplication
}{ ban
Costas Busch - LSU 16
Exponential time algorithms: )2( knTIME
Represent intractable algorithms:Some problem instancesmay take centuries to solve
Costas Busch - LSU 17
Example: the Hamiltonian Path Problem
Question: is there a Hamiltonian path from s to t?
s t
Costas Busch - LSU 18
s t
YES!
Costas Busch - LSU 19
)2()!( knTIMEnTIMEL
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}
Costas Busch - LSU 20
The clique problem
Does there exist a clique of size 5?
Costas Busch - LSU 21
The clique problem
Does there exist a clique of size 5?
Costas Busch - LSU 22
Example: The Satisfiability Problem
Boolean expressions inConjunctive Normal Form:
ktttt 321
pi xxxxt 321Variables
Question: is the expression satisfiable?
clauses
Costas Busch - LSU 23
)()( 3121 xxxx
Satisfiable: 1,1,0 321 xxx
1)()( 3121 xxxx
Example:
Costas Busch - LSU 24
2121 )( xxxx
Not satisfiable
Example:
Costas Busch - LSU 25
e}satisfiabl is expression :{ wwL
)2( knTIMEL
Algorithm: search exhaustively all the possible binary values of the variables
exponential
Costas Busch - LSU 26
Non-DeterminismLanguage class: ))(( nTNTIME
A Non-Deterministic Turing Machine decides each string of length in time
1L
2L3L
))(( nTOn
Costas Busch - LSU 27
0q
iq jq
… … …
… accept
accept
reject
reject
)(nT
(deepest leaf)
depth
All computations of on stringw
nw ||
M
Costas Busch - LSU 28
Non-Deterministic Polynomial time algorithms:
)( knNTIMEL
Costas Busch - LSU 29
k
knNTIMENP )(
The class NP
Non-Deterministic Polynomial time
Costas Busch - LSU 30
Example: The satisfiability problem
Non-Deterministic algorithm:•Guess an assignment of the variables
e}satisfiabl is expression :{ wwL
•Check if this is a satisfying assignment
Costas Busch - LSU 31
Time for variables: n
)(nO
e}satisfiabl is expression :{ wwL
Total time:
•Guess an assignment of the variables
•Check if this is a satisfying assignment )(nO
)(nO
Costas Busch - LSU 32
e}satisfiabl is expression :{ wwL
NPL
The satisfiability problem is a - ProblemNP
Costas Busch - LSU 33
Observation:
NPP
DeterministicPolynomial
Non-DeterministicPolynomial
Costas Busch - LSU 34
Open Problem: ?NPP
WE DO NOT KNOW THE ANSWER
Costas Busch - LSU 35
Example: Does the Satisfiability problem have a polynomial time deterministic algorithm?
WE DO NOT KNOW THE ANSWER
Open Problem: ?NPP
Recommended