Open In App

Construct a Turing Machine for language L = {wwr | w ∈ {0, 1}}

Prerequisite – Turing Machine 

The language L = {wwr | w ∈ {0, 1}} represents a kind of language where you use only 2 character, i.e., 0 and 1. The first part of language can be any string of 0 and 1. The second part is the reverse of the first part. Combining both these parts out string will be formed. Any such string which falls in this category will be accepted by this language. The beginning and end of string is marked by $ sign. For example, if first part w = 1 1 0 0 1 then second part wr = 1 0 0 1 1. It is clearly visible that wr is the reverse of w, so the string 1 1 0 0 1 1 0 0 1 1 is a part of given language. 



Examples –

Input : 0 0 1 1 1 1 0 0
Output : Accepted
Input : 1 0 1 0 0 1 0 1
Output : Accepted

Basic Representation –  Approach 1:

Start from the beginning of the input tape. If the symbol is 0, replace it with Y and move right, or if it’s 1, replace it with X and move right.



Once at the end of the string, move back to the position next to the symbol replaced at the beginning and repeat the process.

In the new state, check if the symbol at the corresponding position from the end matches the one at the beginning. If they match, continue; otherwise, reject the string.

Move left and repeat the process until the entire string is processed.

If all symbols match as expected, accept the string.

Assumption: We will replace 0 by Y and 1 by X. 

Approach Used – First check the first symbol, if it’s 0 then replace it by Y and by X if it’s 1. Then go to the end of string. So last symbol is same as first. We replace it also by X or Y depending on it. Now again come back to the position next to the symbol replace from the starting and repeat the same process as told above. One important thing to note is that since wr is reverse of w of both of them will have equal number of symbols. Every time replace a nth symbol from beginning of string, replace a corresponding nth symbol from the end.

Another solution for the given problem:

If we look at the problem ,it is nothing but an even palindrome so the following is an another solution for the given language. Here I have consider Blank as B. The following turing machine checks that the language L = {wwr | w ∈ {0, 1}} is a palindrome or not. 

Article Tags :