Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
56 views5 pages

TM Tutorial Solution

The document outlines the design of Turing Machines as acceptors and generators for specific language patterns and operations. It includes detailed approaches for accepting strings in the form {a^n b^n | n >= 0} and {w c w | w ∈ (a+b)*}, as well as for adding two binary numbers and computing a^2 in unary representation. Each section provides step-by-step procedures and graphical representations of the Turing Machines involved.

Uploaded by

sawalkarswar
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)
56 views5 pages

TM Tutorial Solution

The document outlines the design of Turing Machines as acceptors and generators for specific language patterns and operations. It includes detailed approaches for accepting strings in the form {a^n b^n | n >= 0} and {w c w | w ∈ (a+b)*}, as well as for adding two binary numbers and computing a^2 in unary representation. Each section provides step-by-step procedures and graphical representations of the Turing Machines involved.

Uploaded by

sawalkarswar
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/ 5

TCS Tutorial Solution_Acceptor

10 May 2025 14:25

Turing Machine as an Acceptor

Q1. Design Turing Machine to accept {a n bn | n >= 0). Simulate for string "aabb"

Ans: Approach:
Step 1: Replace the first a by Blank
Step 2: Move right till last non-Blank symbol.
Step3: Replace last b by Blank.
Step 4: Move left till first non-Blank symbol of tape.
Step 5: Repeat from Step 1.

7-tuple representation of TM

New Section 4 Page 1


Simulation for "aabb"

Ⴡ q0 a a b b B Ⴡ B q1 a b b B Ⴡ B a q1 b b B Ⴡ B a b q1 b B
Ⴡ B a b b q1 B Ⴡ B a b q2 b B Ⴡ B a q3 b B B Ⴡ B q3 a b B B
Ⴡ q3 B a b B B Ⴡ B q0 a b B B Ⴡ B B q1 b B B Ⴡ B B b q1 B B
Ⴡ B B q2 b B B Ⴡ B q3 B B B B Ⴡ B B q0 B B B Ⴡ B B q4 B B B

Q2. Design Turing Machine to accept {w c w| w є (a+b)*).

Ans: Approach:
Step 1: Replace the first symbol by Blank. For input a, go to Step 2 and for input b, go to Step 3.
Step 2: Move right till input is c and go to Step 4 (with memory of leftmost as a)
Step 3: Move right till input is c and go to Step 5 (with memory of leftmost as b)
Step 4: Replace the symbol after c by Blank, if the symbol is a (Skip X, if any) and go to Step 6.
Step 5: Replace the symbol after c by Blank, if the symbol is b (Skip X, if any) and go to Step 6.
Step 6: Move left till first non-Blank symbol of tape.
Step 7: Repeat from Step 1.

7-tuple representation of TM

New Section 4 Page 2


New Section 4 Page 3
TCS Tutorial Solution_Generator
10 May 2025 16:20

Turing Machine as an Generator

Q1. Design Turing Machine to add 2 binary numbers.

Ans:
Assume 2 way infinite model of TM.
Assume input in form "m + n", where m is first number and n is second number (both in Binary representation)

Approach:
Step 1: Move right till last non-Blank symbol (i.e. LSB of n).
Step 2: Decrement n by 1. If n is 0, go to Step 6
Step 3: Move left till LSB of m (i.e. left of +).
Step 4: Increment m by 1.
Step 5: Repeat from step 1.
Step 6: Blank all symbols from last non-Blank symbol on right till + (plus) and stop/ halt.

m has been replaced by m + n

Graphical representation:

Q2. Design Turing Machine to compute a2.

Ans:
Assume input is a, followed by infinite Blank symbols.
Assume that a is represented in Unary where alphabet set is {1}

Approach:
Step 1: Decrement a by 1 (replace by B) and for that add a * and 1 at the end.
Step 2: Repeatedly decrement a by 1 (replace 1 by X) and add 1 after *.

When no more 1s in a, tape has (a-1)-times X, followed by *, followed by a-times 1.

Step 3: Replace all X by 1 to get (a-1) times 1, followed by *, followed by a-times 1.

Now, follow method of multiplication of 2 numbers to get a2

Graphical representation of TM:

New Section 4 Page 4


New Section 4 Page 5

You might also like