Open In App

Construct a Turing Machine for language L = {a^n b^m c^nm where n >=0 and m >= 0}

Prerequisite – Turing Machine The language L = {anbmcnm | n >= 0 and m>=0} represents a kind of language where we use only 3 symbols, i.e., a, b and c. In the beginning, language has n number of a’s followed by m number of b’s and then n*m number of c’s. Any such string which falls in this category will be accepted by this language. 

Examples:



Input : abbcc
Output : YES

Input : abbbcc
Output : NO

Input :  or empty stringOutput : YES 

The basic Representation is as follows: 

  



Start of Computation : The tape contains the input string w, the tape head is on the leftmost symbol of w, and the Turing machine is in the start state Q0. 

Basic Idea : The tape head reads the leftmost symbol of w, which is a and at start only we will make it Blank. Then we will traverse to make leftmost b a $ and replace rightmost c by a Blank, we will do this zigzag pattern of replacing b by $ and c by Blank till all b are not replaced by $.After this we will traverse back in left direction till we get leftmost a and replacing all $ by b in the traversal. After this we have reduced our string into form an-1bmcnm-m so we can figure if all a’s are replaced by blankand if the string belongs to Language L then there will be no c’s left hence it will get accepted.

 

Meanings of symbols used: R, L – direction of movement of one unit on either side. B-Blank, a, b, c -symbols whose combination string is to be tested. $-Temporarily symbol to replace b. 

Working Procedure :

Article Tags :