SlideShare ist ein Scribd-Unternehmen logo
1 von 45
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

Weitere ähnliche Inhalte

Ähnlich wie timecomplexity.ppt

Chapter2vectorvaluedfunction 150105020944-conversion-gate02
Chapter2vectorvaluedfunction 150105020944-conversion-gate02Chapter2vectorvaluedfunction 150105020944-conversion-gate02
Chapter2vectorvaluedfunction 150105020944-conversion-gate02
Cleophas Rwemera
 
Sampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptxSampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptx
HamzaJaved306957
 
Ss important questions
Ss important questionsSs important questions
Ss important questions
Sowji Laddu
 

Ähnlich wie timecomplexity.ppt (20)

Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
Fractal Dimension of Space-time Diagrams and the Runtime Complexity of Small ...
 
df_lesson_01.ppt
df_lesson_01.pptdf_lesson_01.ppt
df_lesson_01.ppt
 
Fractal dimension versus Computational Complexity
Fractal dimension versus Computational ComplexityFractal dimension versus Computational Complexity
Fractal dimension versus Computational Complexity
 
Applied Calculus Chapter 2 vector valued function
Applied Calculus Chapter  2 vector valued functionApplied Calculus Chapter  2 vector valued function
Applied Calculus Chapter 2 vector valued function
 
Chapter2vectorvaluedfunction 150105020944-conversion-gate02
Chapter2vectorvaluedfunction 150105020944-conversion-gate02Chapter2vectorvaluedfunction 150105020944-conversion-gate02
Chapter2vectorvaluedfunction 150105020944-conversion-gate02
 
Computational Complexity: Complexity Classes
Computational Complexity: Complexity ClassesComputational Complexity: Complexity Classes
Computational Complexity: Complexity Classes
 
Sampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptxSampling and Reconstruction (Online Learning).pptx
Sampling and Reconstruction (Online Learning).pptx
 
Winter 8 TM.pptx
Winter 8 TM.pptxWinter 8 TM.pptx
Winter 8 TM.pptx
 
rcg-ch4a.pdf
rcg-ch4a.pdfrcg-ch4a.pdf
rcg-ch4a.pdf
 
Ss important questions
Ss important questionsSs important questions
Ss important questions
 
Ch4 (1)_fourier series, fourier transform
Ch4 (1)_fourier series, fourier transformCh4 (1)_fourier series, fourier transform
Ch4 (1)_fourier series, fourier transform
 
Univariate Financial Time Series Analysis
Univariate Financial Time Series AnalysisUnivariate Financial Time Series Analysis
Univariate Financial Time Series Analysis
 
Ss
SsSs
Ss
 
Deep Learning: Recurrent Neural Network (Chapter 10)
Deep Learning: Recurrent Neural Network (Chapter 10) Deep Learning: Recurrent Neural Network (Chapter 10)
Deep Learning: Recurrent Neural Network (Chapter 10)
 
Signals and Systems.pptx
Signals and Systems.pptxSignals and Systems.pptx
Signals and Systems.pptx
 
Signals and Systems.pptx
Signals and Systems.pptxSignals and Systems.pptx
Signals and Systems.pptx
 
Note and assignment mis3 5.3
Note and assignment mis3 5.3Note and assignment mis3 5.3
Note and assignment mis3 5.3
 
3. Frequency-Domain Analysis of Continuous-Time Signals and Systems.pdf
3. Frequency-Domain Analysis of Continuous-Time Signals and Systems.pdf3. Frequency-Domain Analysis of Continuous-Time Signals and Systems.pdf
3. Frequency-Domain Analysis of Continuous-Time Signals and Systems.pdf
 
Module v sp
Module v spModule v sp
Module v sp
 
International Journal of Mathematics and Statistics Invention (IJMSI)
International Journal of Mathematics and Statistics Invention (IJMSI) International Journal of Mathematics and Statistics Invention (IJMSI)
International Journal of Mathematics and Statistics Invention (IJMSI)
 

Kürzlich hochgeladen

MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
Krashi Coaching
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 

Kürzlich hochgeladen (20)

UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
MSc Ag Genetics & Plant Breeding: Insights from Previous Year JNKVV Entrance ...
 
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
BỘ LUYỆN NGHE TIẾNG ANH 8 GLOBAL SUCCESS CẢ NĂM (GỒM 12 UNITS, MỖI UNIT GỒM 3...
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
Graduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptxGraduate Outcomes Presentation Slides - English (v3).pptx
Graduate Outcomes Presentation Slides - English (v3).pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
ĐỀ THAM KHẢO KÌ THI TUYỂN SINH VÀO LỚP 10 MÔN TIẾNG ANH FORM 50 CÂU TRẮC NGHI...
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 

timecomplexity.ppt