Question

In: Computer Science

Can you give me a turing machine for the language c* n b*2n a* n+2 for...

Can you give me a turing machine for the language c* n b*2n a* n+2 for n>=0 . Please give the entire diagram with states, transition function, alphabet. Can use either one-tape or two-tape (both infinite). Describe the logic used to build the machine. Run the TM that accepts for any string of length > 1. Also run for string cbba.

Solutions

Expert Solution

Solution

The alphabet set is ∑ = {a,b,c}

The strings of the language are {aa,cbbaaa , ccbbbbaaaa , cccbbbbbbaaaaa , ccccbbbbbbbbaaaaaa , ...................}

The turing machine that accepts cnb2nanaa is shown below:

Few strings accepted and rejected by the above Turing machine are shown below:

Logic

Traverse the string from left to right, and each time pick one, c convert it to X. Skip all c's in between and convert the first two unchanged b's to Y. Skip all b's and convert the first unchanged a to Z.

Move backwards to find the first unchanged c and repeat the above step.

If the string is accepted than after reppeating above two steps n times the string will have all X's followed by all Y's , followed by all Z and at the end string will have two a's unchanged.

Example:

The steps how string ccbbbbaaaa is accepted is shown below:

ccbbbbaaaa

XcYYbbZaaa

XXYYYYZZaa

Transition function

a b c X Y Z B
q0 (q6,a,R) (q1,X,R) (q5,Y,R)
q1 (q2,Y,R) (q1,c,R) (q1,Y,R)
q2 (q3,Y,R)
q3 (q4,Z,R) (q3,b,R) (q3,Z,R)
q4 (q4,a,L) (q4,b,L) (q4,c,L) (q0,X,R) (q4,Y,L) (q4,Z,L)
q5 (q6,a,R) (q5,Y,R) (q5,Z,R)
q6 (q7,a,R)
q7 (q8,B,L)
q8

q0 is the start state and q8 is the final state.

Running string cbba

When the string is placed in the tape it will have a blank symbol B, at the end to mark the end of the string.

cbbaB

q0cbbaB

Xq1bbaB

XYq2baB

XYYq3aB

XYYZq4B

Note that in state q4 there is no transition for Blank symbol B. So since q4 is a non final state , the string is rejected.

Running string cbbaaa

When the string is placed in the tape it will have a blank symbol B, at the end to mark the end of the string.

cbbaaaB

q0cbbaaaB

Xq1bbaaaB

XYq2baaaB

XYYq3aaaB

XYYZq4aaB

XYYq4ZaaB

XYq4YZaaB

Xq4YYZaaB

q0XYYZaaB

Xq5YYZaaB

XYq5YZaaB

XYYq5ZaaB

XYYZq5aaB

XYYZaq6aB

XYYZaaq7B

XYYZaq8aB

Since q8 is a final state the string is accepted by the shown turing machine.


Related Solutions

Prove that the language L={(M, N): M is a Turing machine and N is a DFA...
Prove that the language L={(M, N): M is a Turing machine and N is a DFA with L(M) =L(N)} is undecidable. You need to derive a reduction from Atm={(M, w)|Turing machine M accepts w} to L. (In layman's terms please, no other theorems involved)
Implement function matmul() that embodies multiplication of n*n matrix in c language?(code) Can you let me...
Implement function matmul() that embodies multiplication of n*n matrix in c language?(code) Can you let me know?
Explain how a Turing Machine can simulate an arbitrary DFA. Use a 2-tape Turing Machine. It...
Explain how a Turing Machine can simulate an arbitrary DFA. Use a 2-tape Turing Machine. It can be done with a 1-Tape Turing Machine, but 2-tape will likely make the explanation more intuitive.
Design a Turing Machine to construct the function f(n) = 4 [1/4 n] + 2, (that...
Design a Turing Machine to construct the function f(n) = 4 [1/4 n] + 2, (that is, 2 more than 4 times the integer part of 1/4 n) for n Element N. Do not just produce a TM, but also describe briefly how it works. There is a TM in the Cooper notes that does something similar. You may modify it to produce the required TM, or produce a machine totally independently.
Question 1 a) Determine whether the language {a n b m c n | n >...
Question 1 a) Determine whether the language {a n b m c n | n > 0} is regular or not using pumping Lemma. b) Prove that the language {(ai bn | i, n > 0, i = n or i = 2n} is not regular using the Pumping Lemma.
Please write an example of a language that is Turing-decidable but not Context-Free. You can just...
Please write an example of a language that is Turing-decidable but not Context-Free. You can just state what the language is; no need to give a full TM algorithm for it. 1b) Please write an example of a language that is not Turing-decidable. You can just state what the language is; no need to give a full TM algorithm for it.
Define a Turing machine TM3 that decides language L3 = { w | w ∈ Σ*,...
Define a Turing machine TM3 that decides language L3 = { w | w ∈ Σ*, #a(w) = #b(w) } over the alphabet Σ = {a, b}. IMPLEMENT USING JFLAP NO PAPER SOLUTION
Show that the language F={M| M is a Turing machine , and L(M) contains infinite elements}...
Show that the language F={M| M is a Turing machine , and L(M) contains infinite elements} is not Turing recognizable.
Are there computational problems that cannot be solved by a digital computer(or any Turing machine)? Give...
Are there computational problems that cannot be solved by a digital computer(or any Turing machine)? Give one example (that is not computable) and intuitively why it cannot be solved by a digital computer.
Give turing Machine for L= a*i b*2j a*i b*2j where i,j>=0. Also provide the logic, show...
Give turing Machine for L= a*i b*2j a*i b*2j where i,j>=0. Also provide the logic, show 1 or 2 strings for accept, reject .
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT