Chapter One: Complexity Theory Is A Central Topic in Theoretical Computer Science. It Has
Chapter One: Complexity Theory Is A Central Topic in Theoretical Computer Science. It Has
The situation (a) before the move and (b) after the move.
Read-Write head
Control Unit
Read-Write head
Read-Write head
1. Reads a symbol
2. Writes a symbol
3. Moves Left or Right
davidtechnotips.com WSU, COMPUTER SCIENCE DEPARTMENT 14
Example:
Time 0
...... a b a c ......
Time 1
...... a b k c ......
1. Reads a
2. Writes k
3. Moves Left
davidtechnotips.com WSU, COMPUTER SCIENCE DEPARTMENT 15
Time 1
...... a b k c ......
Time 2
...... a f k c ......
1. Reads b
2. Writes f
3. Moves Right
...... a b a c ......
head
Head starts at the leftmost position
of the input string
q1 a b, L q2
Move Right
q1 a b, R q2
davidtechnotips.com WSU, COMPUTER SCIENCE DEPARTMENT 18
Example:1
Time 1
...... a b a c ......
q1
current state
q1 a b, R q2
q1
q1 a b, L q2
q1
Time 2
...... a b b c g ......
q2
q1 q1
q3 a d, L q3
b d, L
q1
a b, R q2 Allowed:
q1 No transition
for input symbol c
b d, L q3
...... a b a c ......
q1
q1 No transition from q1
HALT!!!
...... a b a c ......
q1
a b, R q2
No possible transition
q1 from q1 and symbol c
q3
b d, L HALT!!!
davidtechnotips.com WSU, COMPUTER SCIENCE DEPARTMENT 26
Accepting States
q1 q2
Allowed
q1 q2 Not Allowed
If machine halts
in a non-accept state
Reject Input or
string
If machine enters
an infinite loop
davidtechnotips.com WSU, COMPUTER SCIENCE DEPARTMENT 28
Observation:
In order to accept an input string,
it is not necessary to scan all the
symbols in the string
, L
q0 q1
q0
a a, R
, L
q0 q1
q0
a a, R
, L
q0 q1
q0
a a, R
, L
q0 q1
q0
a a, R
, L
q0 q1
q1
, L
q0 q1
Time 0 a b a
q0
a a, R
, L
q0 q1
q0
No possible Transition
a a, R Halt & Reject
, L
q0 q1
q0
q0
q0
, L
q0 q1
q0
b b, L
a a, R
, L
q0 q1
q0
b b, L
a a, R
, L
q0 q1
q0
b b, L
a a, R
, L
q0 q1
Infinite loop
q0
Time 4 a b a
q0
Time 5 a b a
q0
WSU, COMPUTER SCIENCE
davidtechnotips.com 44
DEPARTMENT
Because of the infinite loop:
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q1
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q2
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q0
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q3
q4 y y, R y y, L
y y, R a a, R
, L a a, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q3
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
q4
Halt & Accept
q4 y y, R y y, L
y y, R a a, R a a, L
, L
y y, R a x, R b y, L
q3 q0 q1 q2
x x, R
davidtechnotips.com WSU, COMPUTER SCIENCE DEPARTMENT 63
davidtechnotips.com WSU, COMPUTER SCIENCE DEPARTMENT 64
The string abab, abb, aab, aaaabb is not accepted by the
TM, because it is not in the form of {a n b n }
The End