0% found this document useful (0 votes)
80 views6 pages

Numericals On Turing Machine

Uploaded by

gauryashu9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views6 pages

Numericals On Turing Machine

Uploaded by

gauryashu9
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Examples of TM

Example 1:
Construct a TM for the language L = {0n1n2n} where n≥1

Solution:

L = {0n1n2n | n≥1} represents language where we use only 3 character, i.e., 0, 1 and 2.
In this, some number of 0's followed by an equal number of 1's and then followed by
an equal number of 2's. Any type of string which falls in this category will be accepted
by this language.

The simulation for 001122 can be shown as below:

Now, we will see how this Turing machine will work for 001122. Initially, state is q0 and
head points to 0 as:

The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0
by A and head will move to the right as:

The move will be δ(q1, 0) = δ(q1, 0, R) which means it will not change any symbol,
remain in the same state and move to the right as:
The move will be δ(q1, 1) = δ(q2, B, R) which means it will go to state q2, replaced 1
by B and head will move to right as:

The move will be δ(q2, 1) = δ(q2, 1, R) which means it will not change any symbol,
remain in the same state and move to right as:

The move will be δ(q2, 2) = δ(q3, C, R) which means it will go to state q3, replaced 2
by C and head will move to right as:

Now move δ(q3, 2) = δ(q3, 2, L) and δ(q3, C) = δ(q3, C, L) and δ(q3, 1) = δ(q3, 1, L) and
δ(q3, B) = δ(q3, B, L) and δ(q3, 0) = δ(q3, 0, L), and then move δ(q3, A) = δ(q0, A, R), it
means will go to state q0, replaced A by A and head will move to right as:

The move will be δ(q0, 0) = δ(q1, A, R) which means it will go to state q1, replaced 0
by A, and head will move to right as:

The move will be δ(q1, B) = δ(q1, B, R) which means it will not change any symbol,
remain in the same state and move to right as:
The move will be δ(q1, 1) = δ(q2, B, R) which means it will go to state q2, replaced 1
by B and head will move to right as:

The move will be δ(q2, C) = δ(q2, C, R) which means it will not change any symbol,
remain in the same state and move to right as:

The move will be δ(q2, 2) = δ(q3, C, L) which means it will go to state q3, replaced 2
by C and head will move to left until we reached A as:

immediately before B is A that means all the 0's are market by A. So we will move right
to ensure that no 1 or 2 is present. The move will be δ(q2, B) = (q4, B, R) which means
it will go to state q4, will not change any symbol, and move to right as:

The move will be (q4, B) = δ(q4, B, R) and (q4, C) = δ(q4, C, R) which means it will not
change any symbol, remain in the same state and move to right as:
The move δ(q4, X) = (q5, X, R) which means it will go to state q5 which is the HALT
state and HALT state is always an accept state for any TM.

The same TM can be represented by Transition Diagram:

Turing Machine for L = {a^n b^n | n>=1}


Task :
We have to design a Turing machine for anbn where n>=1.
Analysis :
We can analyze that we have equal no of a’s and b’s and in some order i.e., first all
a’s will come and then all b’s will come.
Example :
Input-1:aabb
Output-1:YES

Input-2:aabbbb
Output-2:NO

Input-3:abab
Output-3:NO
Approach :
Let us understand the approach by taking the example “aabb”.
 Scan the input from the left.
 First, replace an ‘a’ with ‘X’ and move right. Then skip all the a’s and b’s
and move right.
 When the pointer reaches Blank(B) Blank will remain Blank(B) and the
pointer turns left. Now it scans the input from the right and replaces
the first ‘b’ with ‘Y’. Our Turing machine looks like this –

 Again the pointer reaches Blank(B) or X. It now scans the input from
left to right. The pointer moves forward and replaces ‘a’ with ‘X’.
 Again the pointer reaches Blank(B) or Y. It now scans the input from
the right to left. The pointer moves forward and replaces ‘b’ with ‘y’.
 We repeat the same steps until we convert all the a’s to ‘X’ and b’s to ‘Y’.
 When all the a’s converted to ‘X and all the b’s converted to ‘Y’ our
machine will halt.

You might also like