Formal Languages
Time Complexity
Hinrich Schütze
IMS, Uni Stuttgart, WS 2006/07
Slides based on RPI CSCI 2400
Thanks to Costas Busch
M
L
Consider a deterministic Turing Machine
which decides a language
For any string the computation of
terminates in a finite amount of transitions
w M

Accept
or Reject w
Initial
state

Accept
or Reject w
Decision Time = #transitions
Initial
state
Consider now all strings of length n
)
(n
TM
= maximum time required to decide
any string of length n

)
(n
TM
Max time to accept a string of length n
1 2 3 4 n 
STRING LENGTH
TIME
Time Complexity Class: ))
(
( n
T
TIME
All Languages decidable by a
deterministic Turing Machine
in time
1
L 2
L
3
L
))
(
( n
T
O
Example: }
0
:
{
1 
 n
b
a
L n
Example: }
0
:
{
1 
 n
b
a
L n
This can be decided in time
)
(n
O
)
(n
TIME
}
0
:
{
1 
 n
b
a
L n
)
(n
TIME
}
0
:
{
1 
 n
b
a
L n
}
0
,
:
{ 
k
n
aba
abn
}
even
is
:
{ n
bn
Other example problems in the same class
}
3
:
{ k
n
bn

)
( 2
n
TIME
}
0
:
{ 
n
b
a n
n
Examples in class:
}}
,
{
:
{ b
a
w
ww R

}}
,
{
:
{ b
a
w
ww 
)
( 3
n
TIME
Examples in class:
}
grammar
free
-
context
by
generated
is
:
,
{
2
G
w
w
G
L 
}
and
matrices
:
,
,
{
3
2
1
3
2
1
3
M
M
M
n
n
M
M
M
L




CYK algorithm
Matrix multiplication
Polynomial time algorithms: )
( k
n
TIME
Represents tractable algorithms:
for small we can decide
the result fast
k
constant 0

k
)
( k
n
TIME
)
( 1

k
n
TIME
)
(
)
( 1 k
k
n
TIME
n
TIME 

It can be shown:

0
)
(


k
k
n
TIME
P
The Time Complexity Class P
•“tractable” problems
•polynomial time algorithms
Represents:
P
CYK-algorithm
}
{ n
n
b
a }
{ww
Class
Matrix multiplication
}
{ b
an
Exponential time algorithms: )
2
(
k
n
TIME
Represent intractable algorithms:
Some problem instances
may take centuries to solve
Example: the Hamiltonian Path Problem
Question: is there a Hamiltonian path
from s to t?
s t
s t
YES!
Time?
)
2
(
)
!
(
k
n
TIME
n
TIME
L 

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}
The clique problem
Does there exist a clique of size 5?
The clique problem
Does there exist a clique of size 5?
Example: The Satisfiability Problem
Boolean expressions in
Conjunctive Normal Form:
k
t
t
t
t 


 
3
2
1
p
i x
x
x
x
t 



 
3
2
1
Variables
Question: is the expression satisfiable?
clauses
)
(
)
( 3
1
2
1 x
x
x
x 


Satisfiable?
Example:
)
(
)
( 3
1
2
1 x
x
x
x 


Satisfiable: 1
,
1
,
0 3
2
1 

 x
x
x
1
)
(
)
( 3
1
2
1 


 x
x
x
x
Example:
2
1
2
1 )
( x
x
x
x 


Not satisfiable
Example:
e}
satisfiabl
is
expression
:
{ w
w
L 
)
2
(
k
n
TIME
L 
Algorithm?
exponential
e}
satisfiabl
is
expression
:
{ w
w
L 
)
2
(
k
n
TIME
L 
Algorithm:
search exhaustively all the possible
binary values of the variables
exponential
Non-Determinism
Language class: ))
(
( n
T
NTIME
A Non-Deterministic Turing Machine
decides each string of length
in time
1
L
2
L
3
L
))
(
( n
T
O
n
Non-Deterministic Polynomial time algorithms:
)
( k
n
NTIME
L

0
)
(


k
k
n
NTIME
NP
The class NP
Non-Deterministic Polynomial time
Example: The satisfiability problem
Non-Deterministic algorithm?
e}
satisfiabl
is
expression
:
{ w
w
L 
Example: The satisfiability problem
Non-Deterministic algorithm:
•Guess an assignment of the variables
e}
satisfiabl
is
expression
:
{ w
w
L 
•Check if this is a satisfying assignment
Time for variables:
n
)
(n
O
e}
satisfiabl
is
expression
:
{ w
w
L 
Total time:
•Guess an assignment of the variables
•Check if this is a satisfying assignment )
(n
O
)
(n
O
e}
satisfiabl
is
expression
:
{ w
w
L 
NP
L
The satisfiability problem is an - Problem
NP
Observation:
NP
P 
Deterministic
Polynomial
Non-Deterministic
Polynomial
Open Problem: ?
NP
P 
WE DO NOT KNOW THE ANSWER
Example: Does the Satisfiability problem
have a polynomial time
deterministic algorithm?
WE DO NOT KNOW THE ANSWER
Open Problem: ?
NP
P 
NP-Completeness
A problem is NP-complete if:
•It is in NP
•Every NP problem is reduced to it
(in polynomial time)
Observation:
If we can solve any NP-complete problem
in Deterministic Polynomial Time (P time)
then we know:
NP
P 
Observation:
If we prove that
we cannot solve an NP-complete problem
in Deterministic Polynomial Time (P time)
then we know:
NP
P 
Cook’s Theorem:
The satisfiability problem is NP-complete
Proof:
Convert a Non-Deterministic Turing Machine
to a Boolean expression
in conjunctive normal form
Other NP-Complete Problems:
•The Traveling Salesperson Problem
•Vertex cover
•Hamiltonian Path
All the above are reduced
to the satisfiability problem
Observations:
It is unlikely that NP-complete
problems are in P
The NP-complete problems have
exponential time algorithms
Approximations of these problems
are in P

More Related Content

PDF
practice-final-soln.pdf
PPT
pnp2.ppt
PPTX
Lower bound theory Np hard & Np completeness
PDF
np hard, np complete, polynomial and non polynomial
PDF
Daa notes 3
PPTX
NP completeness
PDF
9. chapter 8 np hard and np complete problems
PPTX
P, NP and NP-Complete, Theory of NP-Completeness V2
practice-final-soln.pdf
pnp2.ppt
Lower bound theory Np hard & Np completeness
np hard, np complete, polynomial and non polynomial
Daa notes 3
NP completeness
9. chapter 8 np hard and np complete problems
P, NP and NP-Complete, Theory of NP-Completeness V2

Similar to timecomplexity.ppt (20)

PPT
Np cooks theorem
PDF
Basic_concepts_NP_Hard_NP_Complete.pdf
PPT
UNIT-V.ppt
PDF
Time complexity
PDF
Computational Complexity: Introduction-Turing Machines-Undecidability
PPTX
Np completeness
PDF
P versus NP
PPTX
Np complete
PPTX
lec2cct computational cmplexity theory.pptx
PPT
NP-Completeewwwwwwwwwwwkkjjejjwjjjjjjjjj
PDF
27 NP Completness
PPT
class23.ppt
PPTX
Presentation.TOA.pptxjiihugydrawagkjiggkfgtsed
DOCX
Ca notes
PPTX
CS2303-TOC.pptx
PPTX
P np &amp; np completeness
PDF
Theory ofcomputation
PPTX
Decidability and Reducability related to TM
PDF
theory of computation chapter 2 notes pdf
PPTX
Deciability (automata presentation)
Np cooks theorem
Basic_concepts_NP_Hard_NP_Complete.pdf
UNIT-V.ppt
Time complexity
Computational Complexity: Introduction-Turing Machines-Undecidability
Np completeness
P versus NP
Np complete
lec2cct computational cmplexity theory.pptx
NP-Completeewwwwwwwwwwwkkjjejjwjjjjjjjjj
27 NP Completness
class23.ppt
Presentation.TOA.pptxjiihugydrawagkjiggkfgtsed
Ca notes
CS2303-TOC.pptx
P np &amp; np completeness
Theory ofcomputation
Decidability and Reducability related to TM
theory of computation chapter 2 notes pdf
Deciability (automata presentation)
Ad

Recently uploaded (20)

PPTX
Computer Architecture Input Output Memory.pptx
PPTX
Module on health assessment of CHN. pptx
PDF
My India Quiz Book_20210205121199924.pdf
PPTX
Education and Perspectives of Education.pptx
PDF
CRP102_SAGALASSOS_Final_Projects_2025.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PPTX
B.Sc. DS Unit 2 Software Engineering.pptx
PDF
Empowerment Technology for Senior High School Guide
PDF
International_Financial_Reporting_Standa.pdf
PPTX
Core Concepts of Personalized Learning and Virtual Learning Environments
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Complications of Minimal Access-Surgery.pdf
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
What’s under the hood: Parsing standardized learning content for AI
PDF
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
PPTX
Climate Change and Its Global Impact.pptx
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
Climate and Adaptation MCQs class 7 from chatgpt
Computer Architecture Input Output Memory.pptx
Module on health assessment of CHN. pptx
My India Quiz Book_20210205121199924.pdf
Education and Perspectives of Education.pptx
CRP102_SAGALASSOS_Final_Projects_2025.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
B.Sc. DS Unit 2 Software Engineering.pptx
Empowerment Technology for Senior High School Guide
International_Financial_Reporting_Standa.pdf
Core Concepts of Personalized Learning and Virtual Learning Environments
AI-driven educational solutions for real-life interventions in the Philippine...
Complications of Minimal Access-Surgery.pdf
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
What’s under the hood: Parsing standardized learning content for AI
BP 505 T. PHARMACEUTICAL JURISPRUDENCE (UNIT 2).pdf
Climate Change and Its Global Impact.pptx
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
Environmental Education MCQ BD2EE - Share Source.pdf
Climate and Adaptation MCQs class 7 from chatgpt
Ad

timecomplexity.ppt