Download as pdf or txt
Download as pdf or txt
You are on page 1of 41

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

SUBJECT NAME: AUTOMATA AND COMPILER DESIGN SUBJECT CODE:U20CST305

Prepared By:
Mr.M.Shanmugam, AP/CSE

Mr. A. Prakash, AP/CSE

Mrs. S.Deeba, AP/CSE

Verifiedby: Approvedby:
UNIT-III

Turing machine s: Turing machine s as Language Acceptors – Turing machine s for Accepting Regular
Languages – Turing machine for Addition and Subtraction.
2 MARKS

1. what is a Turing machine ?(APR 2016, 2017) (NOV2017)


Turing machine (TM), a simple ma the matical model of a computer. the Turing machine models the
computing capability of a general-purpose computer. the Turing machine is studied both for the class of
languages it defines (called the recursively enumerable sets) and the class of integer functions it computes
(called the partial; recursive functions). TM can be divided into n-no of cells (or) squares. TM is similar to
finite automaton but with an unlimited and unrestricted memory. Each cell contain finite no of symbol s
along with blank spaces.

2. what is the basic model of a Turning machine ?


the basic model of a Turing machine has
 a finite control,
 an input tape that is divided into cells, and
 a tape head that scans one cell of the tape at atime.

the tape has a leftmost cell but is in finite to the right. Each cell of the tape may hold exactly one of a
finite number of tape symbol s.

3. what is the function of the Turning machine ?


In one move the Turing machine , depending upon the symbol scanned by the tape head and the
state of the finite control,
1. Changes state ,
2. Prints a symbol on the tape cell scanned, replacing what was written the re, and
3. Moves its head left or right one cell.

4. what is the general form of the Turning machine ?


A Turing machine (TM) is denoted
M = (Q, Σ, Γ, δ, q0, B, F)
where
Q is the finite set of state s,
Γ is the finite set of allowable tape symbol s,
B, a symbol of Γ, is the blank,
Σ, a subset of Γ not including B, is the set of input symbol s,
Δ is the next move function, a mapping from Q x Γ to Q x Γ x {L, R}.
q0in Q is the start state ,
F⊆Q is the set of final state s.

5. what are the representations of the Turning machine ?


1) Instantaneous descriptions
2) Transition table
3) Transition diagram

6. Give the instantaneous description of Turing machine . (APR2015)


An Instantaneous Description (ID) of the Turing machine M is denoted by α1qα2. Here q, the current state
of M is in Q; α1α2 is the string in Γ* that is the contents of the tape up to the rightmost non blank symbol
or the symbol to the left of the head, whichever is rightmost.

7. what do you meant by “Acceptance of Turing machine ”?


In the Turing machine s the re are two halt state s: "accept halt" and "reject halt". A string is accepted by
a Turing machine if given the string, the Turing machine eventually goes into the accept halt state . A
language is a phrase structure (type 0) language if and only if it is Turing-acceptable in ei the r sense and it
has no effects on decidability.

8. Define shifting over?


A Turing machine can make a space on its tape by shifting all non-blank symbol s a finite number of cells
to the right. the tape head makes an excursion to the right, repeatedly storing the symbol s read in its
finite control and replacing the m with symbol s read from dells to the left. the TM can the n return to
the vacated dells and print symbol s of its choosing. If space is available, it can push blocks of symbol s
left in a similar manner.

9. Define subroutines?
As with programs, a “modular” or “top-down” design is facilitated if we use subroutines to define
elementary processes. A Turing machine can simulate any type of subroutine found in programming
languages, including recursive procedures and any of the known parameter-passing mechanisms.
A TM subroutine have to design initial state and a designated return state which has no move and
which will be used to effect a return to the calling routine. To design a TM that “calls” the subroutine, a
new set of state s for the subroutine is made, and a move from the return is effected by the move from the
return state .
10. Write about the storage in the finite Control(FC)? (APR2017)
the finite control can be used to hold a finite amount of information. the state is written as a pair of
elements, one exercising control and the o the r storing a symbol . It should be emphasized that this
arrangement is for conceptual purposes only. No modification in the definition of the Turing machine
has been made.

11. what is Turing machine with in finite tape?


A Turing machine the input tape is in finite at one end ei the r at the left or at the right usually the
right is called a Turing machine with in finite tape.
12. what is a Multi-tape Turing machine s?
A multi tape Turing machine consists of a finite control with k tape heads and k tapes; each tape is in
finite in both directions. On a single move, depending on the state of the finite control and the
symbol scanned by each of the tape heads, the machine can:
1) Change state ;
2) Prints a new symbol on each of the cells scanned by its tape heads;
3) Move each of its tape heads, independently, one cell to the left, or right, or keep it stationary.

13. what is a Non-deterministic Turing machine s?


A Nondeterministic Turing machine is a device with a finite control and a single, one way in finite
tape. For a given state and tape symbol scanned by the tape head, the machine has a finite number
of choices for the next move. Each choice consists of a new state , a tape symbol to print and a direction
of head motion.

14. what is a Multidimensional Turing machine s?


It has a finite control and a tape consisting of k-dimensional array of the cells in finite in all
directions 2k directions, for some fixed k.
 Depending on the state and the symbol scanned,
 the device change state ,
 prints a new symbol , and
 moves its tape head in one of the 2k directions, ei the r positively or negatively along the k-axes.
 Initially the input string is along one axis and the tape head is at the left end of the input string.

15. what is a Multi-head Turing machine s?


A k-head Turing machine has some fixed number, k, of heads. the heads are numbered 1 through k, and a
move of the TM depends on the state and on the symbol scanned by each head. In one move, the
heads may each move independent left, right, or remain stationary.
16. what is an Off-line Turing machine s?
An off-line Turing machine is a multi tape Turing machine whose input tape is read only. the input is
surrounded by end markers, ¢ on the left and $ on the right. the Turing machine is not allowed to
move the input tape head off the region between ¢ and $. the off-line Turing machine copy its own
input onto the extra tape, and it the n simulates M as if the extra tape were M’s input.

17. what is semi-in finite tape?


In case of a Turing machine one side of the input tape is in finite hence it is called as the semi-in finite
tape.

18. what is the language accepted by TM?


the language accepted by M, denoted L(M), is the set of words in Σ * that cause M to enter a final state
when placed, justified at the left on the tape of M, with M in state q0, and the tape head of M at the
leftmost cell. the language accepted by M = (Q, Σ, Γ, δ, q0, B, F)is
{w | w in Σ * and q0w |---* α1 p α2 for some p in F and α1 and α2 in Γ* }.

19. what is Church’s Hypo the sis?


the notion of computable function can be identified with the class of partial recursive functions is known
as Church-hypo the sis or Church-Turing the sis. the Turing machine is equivalent in computing power to
the digital computer.

20. what is multi-stack machine s?


A deterministic two-stack machine is a deterministic Turing machine with a read-only input and two
storage tapes. If a head moves left on ei the r tape, a blank is printed on that tape.

21. what is counter machine s?


Counter machine s, which are off-line Turing machine s whose storage tapes are semi-in finite , and
whose tape alphabets contain only two symbol s, Z and B (blank).

22. what are the applications of Turing machine s?


Turing machine can be used as:
 Recognizers of languages
 Computers of functions on non-negative integers.
 Generating devices
10 MARKS
1. Explain in detail about Turing machine (TM)? (5MARKS)
Turing machine (TM), a simple mathematical model of a computer. the Turing machine models the
computing capability of a general-purpose computer. the Turing machine is studied both for the class of
languages it defines (called the recursively enumerable sets) and the class of integer functions it
computes (called the partial; recursive functions). TM can be divided into n-no of cells (or) squares. TM is
similar to finite automaton but with an unlimited and unrestricted memory. Each cell contain finite no of
symbol s along with blank spaces.

Turning machine Model


It is a more powerful model than many models. It was introduced by Alan Turing in 1936. It can do
everything that a real computer can do. It is mathematical model which recognize recursive enumerable
languages
the basic model of a Turing machine has
 a finite control,
 an input tape that is divided into cells, and
 a tape head that scans one cell of the tape at a time.

the tape has a leftmost cell but is in finite to the right. Each cell of the tape may hold exactly one of a
finite number of tape symbol s. Initially, the n leftmost cells, for some finite n≥0, hold the input, which
is a string of symbol s chosen from a subset of the tape symbol s called the input symbol s. the
remaining infinity of cells each hold the blank, which is a special tape symbol that is not an input symbol .
In one move the Turing machine , depending upon the symbol scanned by the tape head and the
state of the finite control,
1. Changes state ,
2. Prints a symbol on the tape cell scanned, replacing what was written the re, and
3. Moves its head left or right one cell.
Formally, a Turing machine (TM) is
denoted M = (Q, Σ, Γ, δ, q0, B, F)
Where
Q is the finite set of state s,
Γ is the finite set of allowable tape
symbol s, B, a symbol of Γ, is the blank,
Σ, a subset of Γ not including B, is the set of input symbol s,
δ is the next move function, a mapping from Q x Γ to Q x Γ x {L,
R}. q0 in Q is the start state ,
F⊆Q is the set of final state s.

An Instantaneous Description (ID) of the Turing machine M is denoted by α1qα2. Here q, the current
state of M is in Q; α1α2 is the string in Γ* that is the contents of the tape up to the rightmost non blank
symbol or the symbol to the left of the head, whichever is rightmost. Finally, the tape head is assumed
to be scanning the leftmost symbol of α2 or if α2= ε, the head is scanning a blank.
We define a move of M as follows. Let X1X2………XI-1qxi…….Xn be an ID. Let (qi, Xi) = (p, y, L). If i-1=n,
the n take xi as B(blank). If i=1, the n the re is no next ID, as the tape head is not allowed to fall off the left
end of the tape. If i>1, the n we write
X1X2……..XI-1qxi…..Xn├X1X2……XI-2pXI-1YXi+1…..Xn ------------------------------ 1
If δ(q,xi)=(p,y,R), thg en change of ID is
X1X2……..XI-1qXI…..Xn├X1X2……XI-1YpXi+1..Xn --------------------------------------- 2
If i-1=n, the string Xi Xn is empty and the right side of 2 is longer that left side.

the language accepted by M, denoted L(M), is the set of words in Σ * that cause M to enter a final state
when placed, justified at the left on the tape of M, with M in state q0, and the tape head of M at the
leftmost cell. the language accepted by M = (Q, Σ, Γ, δ, q0, B, F)is
{w | w in Σ * and q0w | * α1 p α2 for some p in F and α1 and α2 in Γ* }.

2. Explain Turing machine as a computer of integer functions? (10 MARKS) (NOV2015)


A language that is accepted by a Turing machine is said to be recursively enumerable (r.e.). the term
“enumerable” derives from the fact that it is precisely the se languages whose strings can be enumerated
(listed) by a Turing machine . “Recursively” is a mathematical term predating the computer and it is
similar to recursion.
the class of r.e. language includes some languages for which we common determine membership. If L(M) is
such a language, the n any Turing machine recognizing L(M) must fail to halt on some input not in L(M). If
w is in L(M), M eventually halts on input w. However, M is still running on some input, we can never tell whe
the r M will eventually accept if we let it run long enough, or whether M will run forever.

It is convenient to single out a subclass of the recursively enumerable sets called the recursive sets, which
are those languages accepted by at least one Turing machine that halts on all inputs.
the Turing machine as a computer of integer functions
In addition to being a language acceptor, the Turing machine may be viewed as a computer of functions
from integers to integers. the approach is to represent integers in unary; the integer i≥0 is represented by
the string 0i. If a function has k arguments, i1, i2,…. , ik, the n the se integers are initially placed on the tape
separated by 1’s as 0i110i21…10ik.

If the TM halts (whe the r or not in an accepting state ) with a tape consisting of 0m for some m, the n we
say that f(i1,i2,….,ik)=m, where f is the function of k arguments computed by this Turing machine . Note
that one TM may compute a function of one argument, a different function of two arguments, and so on.
Also note that if TM M computes function f of k arguments, the n feed not have a value for all different k –
tuples of integers i1,….,ik.

If f(i1,i2,………ik) is defined for all i1,…..ik the n we say f is a total recursive function. the total recursive
functions correspond to recursive languages, since the y are computed by TM that always halt. the
common arithmetic functions on integers, such as multiplication, n!, [log 2n] and 22n are total recursive
functions.
A function f(i1,…ik) computed by a Turing machine is called a partial recursive function. the y are similar to
r.e languages as the y are computed by TM that may or may not halt on a given input.

Example: F: N->N
F(x) =x+1(note: blank space replaced by zero) (APR-22) (OCT-22)

Solution
Assume that the input is encoded in unary form. Find first blank (B) and changes it as 0.
Let M= (Q, Σ, Γ, δ, q0, B, F)
Where
Q= {q0, q1}
Σ= {0}
Γ= {0, B}
{q0}=Initial
state F= {q1}

δ transition function,
Inputs
state s
0 B
q0 (q0,0,R) (q1,0,R)
q1 - -
Let us consider output x=3. This can be encoded as 03 and placed on the
tape (q0,000B) ├ (q0,000B)
├ (q0, 000B)
├ (q1, 0000B)

Note
If found 0-> no state
change If found 1 -> state
changed
If found ‘B’-> state changed control transferred to towards left cell.
the machine halts an accepting state q1 computing the successor of x. This can be shown in following figure.

0 0 0 B B……………..

the input 03 placed on the tape followed by blanks.


Initial state =q0
Current input symbol
=0 δ (q0,0)=(q0,0,R)

the first blank symbol is replaced by 0 and the state is changed to q1 which is the acceptance state . the
machine halts as state q1 leaving the output x+1 on the tape.

Concept
From the state q0 on input symbol , it moves right until it sees a blank symbol without changing
the tape symbol or state . On seeing the first blank symbol it is changed to 0, moves right and enters in a
halt string. the tape now will contain the output.
3. Explain the technique for TM Construction in detail? (10 MARKS) (NOV 2017)
Designing Turing machine s by writing out a complete set of state s and a next – move function is a
noticeably unrewarding task. In order to describe complicated Turing machine constructions we need
some “higher – level” conceptual tools.
1. Storage in finite control
2. Multiple tracks
3. Checking off symbol s
4. Shifting over
5. Subroutines

Storage in finite control


the finite control can be used to hold a finite amount of information. the state is written as a pair of
elements, one exercising control and the o the r storing a symbol . It should be emphasized that this
arrangement is for conceptual purposes only. No modification in the definition of the Turing machine has
been made.

Multiple tracks
We can imagine that the tape of the Turing machine is divided into k tracks, for any finite k. This
arrangement is shown in Figure with k=3. the symbol s on the tape are considered k- tuples, one comp
one nt for each track.

A three-track Turing machine


Checking off symbol s
Checking off symbol s is a useful trick for visualizing how a TM recognizes languages defined by repeated
strings, such as
{ww | w in Σ*}, {wcy | w and y in Σ*, w ≠ y} or {wwR| w in Σ*}.
It also useful when lengths of substrings must be compared, such as in the languages
{aibi| i ≥ 1} or {aibick | i ≠ j or j ≠ k}.

Shifting over
A Turing machine can make a space on its tape by shifting all non-blank symbol s a finite number of cells
to the right. the tape head makes an excursion to the right, repeatedly storing the symbol s read in its
finite control and replacing the m with symbol s read from cells to the left. the TM can the n return to
the vacated cells and print symbol s of its choosing. If space is available, it can push blocks of symbol s
left in a similar manner.

Subroutines (OCT-22)
As with programs, a “modular” or “top-down” design is facilitated if we use subroutines to define elementary
processes. A Turing machine can simulate any type of subroutine found in programming languages,
including recursive procedures and any of the known parameter-passing mechanisms.
A TM subroutine have to design initial state and a designated return state which has no move and which
will be used to effect a return to the calling routine. To design a TM that “calls” the subroutine, a new set of
state s for the subroutine is made, and a move from the return is effected by the move from the return
state .

4. Explain various types of Turing machine with neat sketch. (10MARKS) (APR2015) (APR-22) (OCT-22)
the variations or modifications of the Turing machine s are
1. Two-way in finite Tape
2. Multi-Tape Turing machine s
3. Non-Deterministic Turing machine s
4. Multi-Dimensional Turing machine s
5. Multi-Head Turing machine s
6. Off-Line Turing machine s

Two-way in finite Tape


A Turing machine with a two-way in finite tape is denoted
by M= (Q, Σ, Γ, δ, q0, B, F)
A finite automation is a control unit that reads a tape, moving one square right at each move. Two way
finite automaton is an extension of one - way finite automaton which has the ability to allow the tape
head to move left as well as right.
the input tape is in finite to the left as well as to the right. We denote an Instantaneous Description (ID)
such a device for the one -way in finite TM. However, the re is an infinity of blank cells both to the left
and right of the current non-blank portion of the tape.

Multi-tape Turing machine s


A multi tape Turing machine consists of a finite control with k tape heads and k tapes; each tape is in
finite in both directions. On a single move, depending on the state of the finite control and the symbol
scanned by each of the tape heads, the machine can:
1. Change state ;
2. Prints a new symbol on each of the cells scanned by its tape heads;
3. Move each of its tape heads, independently, one cell to the left, or right, or keep it
stationary. Initially, the input appears on the first tape and the o the r tapes are blank.

Non-deterministic Turing machine s


A Nondeterministic Turing machine is a device with a finite control and a single, one way in finite tape.
For a given state and tape symbol scanned by the tape head, the machine has a finite number of choices
for the next move.
Each choice consists of
 a new state ,
 a tape symbol to print and
 a direction of head motion.

Non-deterministic TM is not permitted to make a move in which


 changes its state to the next state
 write a symbol on the tape
 move its tape head to the left or right one cell or not
Non-deterministic TM accepts its input if a sequence of choices of moves leads to an accepting state .

Multidimensional Turing machine s


It has a finite control and a tape consisting of k-dimensional array of the cells in finite in all
directions 2k directions, for some fixed k.
Depending on the state and the symbol scanned,
 the device changes state ,
 prints a new symbol , and
 moves its tape head in one of the 2k directions, ei the r positively or negatively along the k-axes.
 Initially the input string is along one axis and the tape head is at the left end of the input string.

At any time, only a finite number of rows in any dimension contain non-blank symbol s. This rows each
have only a finite no. of non-blank symbol s.

Example: Consider the tape configuration of the two-dimensional


TM. (a). Draw a rectangle about the non-blank symbol s.
(b) . the rectangle can be represented row by row on a single tape. the *’s separate the rows. A second
track may be used to indicate the position of the two-dimensional TM’s tape head.

Multi-head Turing machine s


A k-head Turing machine has some fixed number, k, of heads. the heads are numbered 1 through k, and a
move of the TM depends on the state and on the symbol scanned by each head. In one move, the
heads may each move independent left, right, or remain stationary.

Off-line Turing machine s


An off-line Turing machine is a multi tape Turing machine whose input tape is read only. the input is
surrounded by end markers, ¢ on the left and $ on the right. the Turing machine is not allowed to move
the input tape head off the region between ¢ and $. the off-line Turing machine copy its own input onto
the extra tape, and it the n simulates M as if the extra tape were M’s input.
5. Design a Turing machine M that computes x + y where x and y are positive integers.
(10MARKS) (APR2015)
For decimal addition f(x, y) = x + y. We will start with x + y on the tape and end with the sum on the tape.
the idea is to decrement y and increment x, until y becomes 0. First we decrement y with the following
TM:
 Move to the rightmost digit iny.
 Repeat the following steps un tild one .
 If the current symbol under the tape head is +, the n clear y and go to the start of x and stop ( the
addition is complete).
 If the current symbol is any digit is anything o the r than a 0, decrement the current digit under tape
head by 1 (replace the digit with the next lower digit) and proceed to increment x by one . the
decrementing isd one .
 If the current symbol under tape is 0, replace it with 9 and move the tape head to the left.
Continue from Repeat.

the n we increment x with the following TM:


 Move to the rightmost digit inx.
 Repeat the following steps untild one .
 If the symbol under the tape head is a blank, write a1.
 If the symbol under the tape head is any digit o the r than 9, increment the current digit under tape
head by 1 (replace the digit with the next higher digit) and proceed to decrement y. We have
finished the increment.
 If the current digit under tape head is 9, replace it with 0 and move the tape head to the left.
Continue from Repeat.

Turing machine as Adder


Approach for Addition
1. Numbers are given in Uniary form.
2. Example: 3 = 111, 2 = 11, 5 = 11111 etc.
3. For addition of 3 and 4, numbers will be given in TAPE as "B B 1 1 1 0 1 1 1 1BB".
4. Convert '0' to '1' and reduce '1' from right.
5. Henceoutputwillbe"BB111111 1BBB".
6. Total number of '1' in output is = 7 which is addition of 3 and 4.
Tape Movement for String "110111":

Explanation of Tape Movement:


1. Input is given as "11011" (2 +2)
2. Scan string from left to right
3. Pass all '1'SSS and convert '0' to'1'
4. Reach BLANK in right
5. Convert rightmost '1' to BLANK
Addition of 2 and 2 = 4 is written on
TAPE
Input String : 11011
Output String : 1111

state Transition Diagram


We have designed state transition diagram for adder as follows:
1. Start scanning string from left to right.
2. Pass all '1's and keep moving right.
3. Convert '0' to '1' and keep moving right.
4. When LANK (in right) is reached move one step left convert '1' to BLANK.
5. Keep moving left after that to point start of string.
6. Number of '1's is reduced because number of '1' was increased by one while converting '0'to'1'.
Example:

9. Construct Turing machine for binary language of palindrome strings. (10 MARKS)(NOV2016)(APR-22)
the TM scans the first symbol of input tape (a or b), erases, that is replaces it with Blank symbol B and
changes state (q1, or q2). TM scans the remaining part without changing the tape symbol until it
encounters blank symbol B. the n the read write head moves to the left. If the rightmost symbol tallies
with the leftmost symbol (Which can be erased but remembered), the rightmost symbol is erased o the
rwise TM halts. the read write head moves to the left until blank B is encountered. the above steps are
repeated after changing the state s suitably.
Transition Table:

Transition Functions:
δ(q0,a) = (q1,B,R)
δ(q0,b) = (q2,B,R)

δ(q1,a) =(q1,a,R)
δ(q1,b) =(q1,b,R)
δ(q1,B) =(q3,B,L)

δ(q2,a) =(q2,a,R)
δ(q2,b) =(q2,b,R)
δ(q2,B) =(q4,B,L)

δ(q3,a) =(q5,B,L)
δ(q5,a) =(q5,a,L)
δ(q5,b) =(q5,b,L)
δ(q5,B) =(q0,B,R)

δ(q4,b) =(q6,B,L)
δ(q6,a) =(q6,a,L)
δ(q6,b) =(q6,b,L)
δ(q6,B) =(q0,B,R)

δ(q0,B) =(q7,B,R)
Transition Diagram:
10. Design Turing machine for the following language { an bn cn, n≥1}. (10MARKS)(APR 2016)
(NOV2017) (OCT-22)

Approach for { anbn cn | n ≥ 1 }


1. Mark 'a' the n move right.
2. Mark 'b' the n move right
3. Mark 'c' the n move left
4. Come to far left till we get 'X'
5. Repeat above steps till all 'a', 'b' and 'c' are marked
6. At last if everything is marked that means string is accepted.

Tape movement for string "aaabbbccc":


Explanation of Tape Movement:
Step 1-2
1. Input is given as "aaabbbccc" (scan string from left to right).
2. Mark 'a' as 'X' and move one step right.
3. Reach unmarked 'b' and pass every 'a' and 'Y'(in case) on the way to'b'.

Step 3-4
4. Mark 'b' as 'Y' and move one step right.
5. Reach unmarked 'c' and pass every 'b' and 'Z'(in case) on the way to 'c'.
6. Mark 'c' as 'Z' and move one step left cause now we have to repeat process.
7. Reach unmarked 'X' and pass every 'Z', 'b', 'Y', 'a' on the way to 'X'.
8. Move to 'a' and repeat the process.

Step 5-9
9. Step 1-4 are repeated.

Step 10
10. When TAPE header reaches 'X' and next symbol is 'Y' that means 'a's are finished.
11. Check for 'b's and 'c's by going till BLANK (in right) and passing 'Y' and 'Z' on the way.
12. If no 'b' and 'c' are not found that means string is accepted.

state Transition Diagram


We have designed state transition diagram for anbn cn | n ≥ 1 as follows:
1. Following Steps:
a. Mark 'a' with 'X' and move towards un marked 'b'.
b. Move towards unmarked 'b' by passing all 'a's.
c. To move towards unmarked 'b' also pass all 'Y's if exist.

2. Following Steps:
a. Mark 'b' with 'Y' and move towards un marked 'c'.
b. Move towards unmarked 'c' by passing all 'b's.
c. To move towards unmarked 'c' also pass all 'Z's if exist.
3. Following Steps:
a. Mark 'c' with 'Z' and move towards first 'X' (in left).
b. Move towards first 'X' by passing all 'Z's, 'b's, 'Y's and 'a's.
c. When 'X' is reached just move one step right by doing nothing.

4. To check all the 'a's,'b's and 'c's are over add loops for checking 'Y' and 'Z' after" weget 'X' followed by
'Y'". To reach final state (qf) just replace BLANK with BLANK and move ei the r direction.
12. Construct a Turing machine that canmultiply2integers. (10MARKS) (NOV2016)
Turing machine for Regular languages

Regular languages can be represented through finite automata and similarly can be
represented through Turing machine .

This machine must accept all strings starting from a and ending with b. e.g, ab,aab, abab etc.

Let’s discuss the diagram;

Start:
Starts the machine
a,a,R:
Read a from input tape and write a and move Right on input tape.

state 2:
Read a from input tape and write a and move Right on input tape. the re is a loop of a, a, R on state
2.
If read b from input tape, the n write b and move right and halts the machine by accepting the
string.
If the re is any a on accept state the n again control moves to the state 2, enforcing the machine to
not end with a.

Turing machine Diagram

Demo of Turing machine Execution

Question: String ab can be ready by this Turing machine or not? If it can be read the n what will be
the path?
Answer:
Yes, this string can be read by the Turing machine in the Path of machine execution is mentioned
below.
Path: start > 2 > accept.

Question: String ba can be ready by this Turing machine or not? If it can be read the n what will be
the path?
Answer: Sorry this string can’t be read by this Turing machine because this machine only can read
the strings that are started with alphabet a

Question: String abbba can be ready by this Turing machine or not? If it can be read the n what will
be the path?
Answer:
Answer: Sorry this string can’t be read by this Turing machine because this machine only can read
the strings ended with alphabet b.
Path: start > 2 > accept > accept > accept > 2. Here, 2 is the ending state but actual ending state is
“accept”.

Question: String ababab can be ready by this Turing machine or not? If it can be read the n what will
be the path?
Answer:
Yes, this string can be read by the Turing machine in the Path of machine execution is menti one d
below.
Path: start > 2 > accept > 2 > accept > 2 > accept.

Question: String abbbb can be ready by this Turing machine or not? If it can be read the n what will
be the path?
Answer:
Yes, this string can be read by the Turing machine in the Path of machine execution is menti one d
below.
Path: start > 2 > accept > accept > accept > accept.

Question: String baabbb can be ready by this Turing machine or not? If it can be read the n what will
be the path?
Answer: Sorry this string can’t be read by this Turing machine because this machine only can read
the strings that are started with alphabet a.

Question: String aababb can be ready by this Turing machine or not? If it can be read the n what will
be the path?
Answer: Yes, this string can be read by the Turing machine in the Path of machine execution is
mentioned below.
Path: start > 2 > 2 > accept > accept > accept.
Turing machine for Subtraction
PONDICHERRY UNIVERSITY QUESTIONS

2 MARKS

1. Does a NTM accept a language, accepted by TM(or DTM)?Justify.(APR2015)(Ref.Qn.No.34,Pg.no.7)


2. Give the instantaneous description of Turing machine .(APR2015)(Ref.Qn.No.6,Pg.no.3)
3. List the techniques for Turing machine construction?(NOV2015)(Ref.Qn.No.10,Pg.no.3)
4. what is a Turning machine ? (APR 2016, 2017) (NOV 2017) (Ref.Qn.No.1,Pg.no.2)
5. what is the storage in FC? (APR 2017) (Ref.Qn.No.14,Pg.no.4)

10 MARKS

APRIL 2015 (REGULAR)


1. Design a Turing machine M that computes x + y where x and y are positive integers.
(Ref.Qn.No.7, Pg.no.22)

NOVEMBER 2015 (ARREAR)


1. Explain Turing machine as a computer of integer functions with an example.(Ref.Qn.No.2,Pg.no.9)

APRIL 2016 (REGULAR)


1. Discuss the working of various Turing machine s.(Ref.Qn.No.4,Pg.no.13)

NOVEMBER 2016 (ARREAR)


1. Construct Turing machine for binary language of palindrome strings. (Ref.Qn.No.10,
Pg.no.27) (OR)
2. Construct a Turing machine that can multiply 2 integers. (Ref.Qn.No.12,Pg.no.32)

APRIL 2016 (REGULAR)


1. Design Turing machine to recognize the language{0n1n0n,n≥1}.(Ref.Qn.No.11,Pg.no.29)

NOVEMBER 2017 (ARREAR)


1. Explain the procedure to construct Turing machine .(Ref.Qn.No.3,Pg.no.12)
(OR)
2. Design Turing machine for the following language { anbncn, n≥1}.(Ref.Qn.No.11,Pg.no.29)

MAY 2018
1. Construct Turing machine for L={0n 1n /n>=1}(11makrs)
(OR)
2. Construct a Turing machine that can find the reverse of a binary string(11marks)
MAY 2019

1. Design a Turing machine which accepts strings which begin with a letter followed by letter or Digits.

You might also like