Turing Machine Part 2 Example (2) (3)
Turing Machine Part 2 Example (2) (3)
1.Step 3-4
Mark 'b' as 'Y' and move one step right
2.Reach unmarked 'c' and pass every 'b' and 'Z'(in case) on the way to 'c'
3.Mark 'c' as 'Z' and move one step left cause now we have to repeat
process
4.Reach unmarked 'X' and pass every 'Z', 'b', 'Y', 'a' on the way to 'X'
5.Move to 'a' and repeat the process
1.Step 5-9
Step 1-4 are repeated
2.Step 10
When TAPE header reaches 'X' and next symbol is 'Y' that means 'a's are finished
3.Check for 'b's and 'c's by going till BLANK(in right) and passing 'Y' and 'Z' on the
way
4.If no 'b' and 'c' are not found that means string is accepted
A string w is called palindrome if reading w from left to right gives the same result as
reading w from right to left. An even palindrome has even number of symbols.
Basic Idea :
The tape head reads the leftmost symbol of w, deletes this symbol and “remembers” it by means of
a state. Then the tape head moves to rightmost symbol and tests whether it is equal to the (already
deleted) leftmost symbol.
If they are equal, then the rightmost symbol is deleted, the tape head moves to the new leftmost
symbol, and the whole process is repeated . Else the machine can’t reach the final state and the
string will be rejected.
We can reach the end of the string when we get Blank as the input symbol then we change state
to Q2 and test if the previous symbol is “a” then we change to state Q3 and then only we will
replace it by Blank and we have successfully tested that string is palindrome till this point now we
will traverse back or leftwards (keeping a and b unchanged which comes in way) on the string and
till we get Blank which is the symbol which we made Blank at the start and we change state to
Q0.Now we repeat the same procedure for “b” as input.
Step-3:
If the string was palindrome then there will be only Blank symbol left and hence we test it at Q0 if
we get blank hence the string gets accepted and is palindrome, at this point there is one more
condition is included which is of null string or empty string is palindrome should be accepted
Construct a Turing machine for L = {aibjck | i*j = k; i, j, k ≥ 1}
Solution:
1. First scan the string from left to right to verify that it is of form a+b+c+;
if it is scan to start of tape* and if not, reject. Easy to do with finite
control/FA.
2. Cross off the first a and scan until the first b occurs. Shuttle between
b’s and c’s crossing off one of each until all b’s are gone. If all c’s have
been crossed off and some b’s remain, reject.
3. Restore** the crossed off b’s and repeat step 2 if there are a’s
remaining. If all a’s gone, check if all c’s are crossed off; if so, accept;
else reject.
Turing machine for M1 that accepts strings of {w#w|w ∈ {0, 1}
∗}.
Turing machine for M1 that accepts strings of {w#w|w ∈ {0, 1}
∗}.
It works as follows:
1. Scan the input to be sure that it contains a single # symbol. If not, reject.
2. Zig-zag across the tape to corresponding positions on either side of the # symbol to
check whether these positions contain the same symbol. If they do not, reject.
Cross off symbols as they are checked.
3. When all symbols to the left of # have been crossed off, check for any remaining
symbols to the right of the #. If any symbols remain, reject; otherwise, accept.
Turing machine for M1 that accepts strings of {w#w|w ∈ {0, 1} ∗}.