The Wayback Machine - https://web.archive.org/web/20240607083333/https://www.geeksforgeeks.org/construct-a-turing-machine-for-l-aibjck-ij-k-i-j-k-%e2%89%a5-1/
Open In App

Construct a Turing machine for L = {aibjck | i*j = k; i, j, k ≥ 1}

Last Updated : 15 May, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Prerequisite – Turing Machine 
In a given language, L = {aibjck | i*j = k; i, j, k ≥ 1}, where every string of ‘a’, ‘b’ and ‘c’ has a certain number of a’s, then a certain number of b’s and then a certain number of c’s. The condition is that each of these 3 symbols should occur at least once. ‘a’ and ‘b’ can occur however many times, but the occurrences of ‘c’ must be equal to the product of occurrences of ‘a’ and occurrences of ‘b’. Assume that string is ending with ‘$’. 

Examples – 
 

Input: a a b b b c c c c c c  
Here a = 2, b = 3, c = 2 * 3 = 6
Output: ACCEPTED

Input: a a b b c c c
Here a = 2, b = 2, c = 3 but c should be 4 (c=2*2 must be 4 but here c=3)
Output: NOT ACCEPTED

Approach used – Scan the input from the left. 
 

  1. First, replace an ‘a’ with ‘X’ and move 1 step right. Then skip all the a’s and move right. 
  2. When the pointer reaches the first ‘b’ stop. Replace one ‘b’ with ‘Y’, then move right skipping all intermediate b’s and corresponding to the replaced ‘b’ now replace one ‘c’ with ‘Z’ and move left. 
  3. Now move towards the left skipping all ‘Z’ and ‘b’ in the way. 
  4. When the pointer reaches the most recent ‘Y’ move right. 
  5. If the pointer is pointing at ‘b’ then repeat steps 2 to 4, else if the pointer is pointing at ‘Z’ then move towards left while replacing all ‘Y’ to ‘b’ and skipping all a’s. 
  6. When the pointer comes to the most recent ‘X’ move one step right. 
  7. If the pointer is still pointing to ‘a’ then repeat all the above steps, else if the pointer is at ‘y’ then move towards right skipping all ‘y’ and ‘Z’. 
  8. When $ is reached then move left. The string is ACCEPTED. 
     

 

 


Previous Article
Next Article

Similar Reads

Construct Turing machine for L = {a<sup>n</sup> b<sup>m</sup> a<sup>(n+m)</sup> | n,m≥1}
L = {an bm a(n+m) | n,m≥1} represents a kind of language where we use only 2 character, i.e., a and b. The first part of language can be any number of "a" (at least 1). The second part be any number of "b" (at least 1). The third part of language is a number of "a" whose count is sum of count of a's in first part of string and count of b's in secon
3 min read
Construct a Turing Machine for language L = {0<sup>n</sup>1<sup>n</sup>2<sup>n</sup> | n≥1}
Prerequisite - Turing Machine The language L = {0n1n2n | n≥1} represents a kind of language where we use only 3 character, i.e., 0, 1 and 2. In the beginning language has some number of 0's followed by equal number of 1's and then followed by equal number of 2's. Any such string which falls in this category will be accepted by this language. The be
3 min read
Construct a Turing machine for L = {a<sup>i</sup>b<sup>j</sup>c<sup>k</sup> | i&lt; j&lt; k; i &ge; 1}
Prerequisite – Turing Machine In given language L = {aibjck | i&lt; j&lt; k; i&ge; 1}, every string of ‘a’, ‘b’ and ‘c’ have certain number of a’s, then certain number of b’s and then certain number of c’s. The condition is that count of 1st symbols should be atleast 1. ‘b’ and ‘c’ can have thereafter be as many but count of a is less than count of
3 min read
Construct a Turing machine for L = {a<sup>i</sup>b<sup>j</sup>c<sup>k</sup> | i &lt; j &lt; k or i &gt; j &gt; k}
Prerequisite – Turing Machine The language L = {aibjck | i &lt; j &lt; k or i &gt; j &gt; k} is same as the union of two languages L1={aibjck | i &lt; j &lt; k } and L2={aibjck | i &gt; j &gt; k } In this language, every string of ‘a’, ‘b’ and ‘c’ have certain number of a’s, then certain number of b’s and then certain number of c’s. The condition i
5 min read
Construct Pushdown automata for L = {0<sup>n</sup>1<sup>m</sup>2<sup>m</sup>3<sup>n</sup> | m,n ≥ 0}
Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Pushdown automata (PDA) plays a significant role in compiler design. Therefore there is a need to have a good hands on PDA. Our aim is to construct a PDA for L = {0n1m2m3n | m,n ≥ 0} Examples - Input : 00011112222333 Output : Accepted Input : 0001122233 Output : Not Accep
3 min read
NPDA for accepting the language L = {a<sup>m</sup> b<sup>n</sup> c<sup>p</sup> d<sup>q</sup> | m+n=p+q ; m,n,p,q&gt;=1}
Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Problem - Design a non deterministic PDA for accepting the language L = {[Tex]a^m[/Tex] [Tex]b^n[/Tex] [Tex]c^p[/Tex] [Tex]d^q[/Tex] | m + n = p + q : m, n, p, q&gt;=1}, i.e., L = {abcd, abbcdd, abbccd, abbbccdd, ......} In each of the string, the total number of 'a' and
2 min read
NPDA for accepting the language L = {a<sup>i</sup>b<sup>j</sup>c<sup>k</sup>d<sup>l</sup> | i==k or j==l,i&gt;=1,j&gt;=1}
Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Problem - Design a non deterministic PDA for accepting the language L = {[Tex]a^i[/Tex] [Tex]b^j[/Tex] [Tex]c^k[/Tex] [Tex]d^l[/Tex] : i==k or j==l, i&gt;=1, j&gt;=1}, i.e., L = {abcd, aabccd, aaabcccd, abbcdd, aabbccdd, aabbbccddd, ......} In each string, the number of a
3 min read
Construct a Turing Machine for language L = {0<sup>2n</sup>1<sup>n</sup> | n&gt;=0}
Prerequisite - Turing Machine The language L = {02n1n | n &gt;= 0} represents a kind of language where we use only 2 symbols, i.e., 0 and 1. In the beginning language has some number of 0's followed by exactly half number of 1's . Any such string which falls in this category will be accepted by this language. Examples : Input : 001 Output : YES Inp
2 min read
Construct Pushdown automata for L = {0<sup>m</sup>1<sup>(n+m)</sup>2<sup>n</sup> | m,n &ge; 0}
Prerequisite – Pushdown automata, NPDA for accepting the language L = {amb(n+m)cm | m, n &gt;= 1} Problem: Construct Pushdown automata for L = {0m1(n+m)2n | m,n &ge; 0} Example: Input: 011122 Output: Accepted Input: 00000112222 Output: Not Accepted Approach used in this PDA – There can be four cases while processing the given input string. Case 1-
2 min read
Construct Pushdown automata for L = {0<sup>(n+m)</sup>1<sup>m</sup>2<sup>n</sup> | m, n &ge; 0}
Prerequisite – Pushdown automata Problem: Construct Pushdown automata for L = {0(n+m)1m2n | m, n &ge; 0} Similar PDA's- This PDA seems to be similar to PDA of S2 = {0m1(n+m)2n} but the production is different. S2 will produce output which have no of 1's equal to the sum of no of 0's and 2's, while S1 does not. This PDA seems to be similar to PDA of
3 min read
Article Tags :