asked 231k views
4 votes
Consider the (non-regular) language of all strings of 0s followed by an equal number of 1s and then an equal number of 2s, 1k L = {012, 001122, 000111222, 000011112222, ...} = 0^k,1^k, 2^k

a. Describe how a Turing machine would accept the string 000001111122222

asked
User Kroe
by
8.0k points

1 Answer

2 votes

Answer:

To accept the string 000001111122222 in the language L, a Turing machine would need to verify that the string has an equal number of 0s, 1s, and 2s. One possible way to do this is as follows:

Start at the beginning of the input tape, on the first 0.

Scan to the end of the tape, marking each 0, 1, and 2 encountered as visited.

If the number of visited 0s, 1s, and 2s are all equal, accept the input; otherwise, reject it.

This algorithm relies on the fact that the input is of the form 0^k 1^k 2^k for some value of k, meaning that there will be exactly k 0s, k 1s, and k 2s in the input. By marking each visited symbol and ensuring that the number of marks for each symbol is the same at the end of the input, the algorithm can determine if the input is in the language L.

Step-by-step explanation:

answered
User Matthew Pape
by
8.4k points