The Wayback Machine - https://web.archive.org/web/20240607081828/https://www.geeksforgeeks.org/npda-for-accepting-the-language-l-aibjckdl-ik-or-jli1j1/
Open In App

NPDA for accepting the language L = {aibjckdl | i==k or j==l,i>=1,j>=1}

Last Updated : 28 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report
Prerequisite – Pushdown automata, Pushdown automata acceptance by final state Problem – Design a non deterministic PDA for accepting the language L = {a^i b^j c^k d^l : i==k or j==l, i>=1, j>=1}, i.e.,
L = {abcd, aabccd, aaabcccd, abbcdd, aabbccdd, aabbbccddd, ......} 
In each string, the number of a’s are followed by any number of b’s and b’s are followed by the number of c’s equal to the number of a’s and c’s are followed by number of d’s equal number of b’s. Explanation – Here, we need to maintain the order of a’s, b’s, c’s and d’s.That is, all the a’s are coming first then all the b’s are coming and then all the c’s are coming then all the d’s are coming . Thus, we need a stack along with the state diagram. The count of a’s and b’s is maintained by the stack.We will take 2 stack alphabets:
\Gamma = { a, b, c, d, z } 
Where, \Gamma = set of all the stack alphabet z = stack start symbol Approach used in the construction of PDA – In designing a NPDA, for every a’, ‘b’, ‘c’ and ‘d’ will comes in proper order.
  • For i==k : Whenever ‘a’ comes, push it in stack and if ‘a’ comes again then also push it in the stack.After that, if ‘b’ comes not do any operation. After that, when ‘c’ comes then pop ‘a’ from the stack each time.After that, if ‘d’ comes not do any operation.
  • For j==l : Whenever ‘a’ comes, not do any operation.After that, if ‘b’ comes push it in stack and if ‘b’ comes again then also push it in the stack. After that, when ‘c’ comes not do any operation.After that, if ‘d’ comes then pop ‘b’ from the stack each time.
So that the stack becomes empty.If stack is empty then we can say that the string is accepted by the PDA. Stack transition functions –
\delta(q0, a, z) \vdash (q1, az)
\delta(q0, a, z) \vdash (q3, z)
\delta(q1, a, a) \vdash (q1, aa)
\delta(q1, b, a) \vdash (q1, a)
\delta(q1, c, a) \vdash (q2, \epsilon) 
\delta(q2, c, a) \vdash (q2, \epsilon) 
\delta(q2, d, \epsilon ) \vdash (q2, \epsilon) 
\delta(q2, \epsilon, z) \vdash (qf1, z)   
\delta(q3 a, z) \vdash (q3, z)
\delta(q3 b, z) \vdash (q3, bz)
\delta(q3 b, b) \vdash (q3, bb)
\delta(q3 c, b) \vdash (q3, b)
\delta(q3, d, b) \vdash (q4, \epsilon) 
\delta(q4, d, b) \vdash (q4, \epsilon) 
\delta(q4, \epsilon, z) \vdash (qf2, z)   
Where, q0 = Initial state qf1, qf2 = Final state \epsilon = indicates pop operation So, this is our required non deterministic PDA for accepting the language L ={a^i b^j c^k d^l : i==k or j==l, i>=1, j>=1}.

Previous Article
Next Article

Similar Reads

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>n</sup> b<sup>n</sup> c<sup>m</sup> | m,n&gt;=1}
Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Problem – Design a non deterministic PDA for accepting the language L = {[Tex]a^n[/Tex] [Tex]b^n[/Tex] [Tex]c^m[/Tex] | m, n&gt;=1}, i.e., L = { abc, abcc, abccc, aabbc, aaabbbcc, aaaabbbbccccc, ...... } In each of the string, the number of a's is equal to number of b's.
2 min read
NPDA for accepting the language L = {a<sup>2m</sup>b<sup>3m</sup> | m &ge; 1}
Prerequisite - Pushdown automata, Pushdown automata acceptance by final state Problem – Design a non deterministic PDA for accepting the language L = {a2mb3m | m &ge; 1}, i.e., L = {aabbb, aaaabbbbbb, aaaaaabbbbbbbbb, aaaaaaaabbbbbbbbbbbb, ......} In each of the string, for every 2 'a's there is 3 'b'. Explanation – Here, we need to maintain the or
2 min read
NPDA for accepting the language L = {a<sup>n</sup>b<sup>m</sup> | n,m &ge; 1 and n &ne; m}
Prerequisite – Pushdown automata, Pushdown automata acceptance by final state Problem – Design a non deterministic PDA for accepting the language [Tex]L = \{a^n b^m | n, m \geq 1 \text{and n!=m}\}[/Tex], i.e., L = {aab, abb, aaab, abbb, aaaab, aaabb, aabbb, abbbb ......} In each of the string, the number of a’s are followed by unequal number of b’s
2 min read
NPDA for L = {0<sup>i</sup>1<sup>j</sup>2<sup>k</sup> | i==j or j==k ; i , j , k &gt;= 1}
Prerequisite - Pushdown automata, Pushdown automata acceptance by final state The language L = {0i1j2k | i==j or j==k ; i , j , k &gt;= 1} tells that every string of ‘0’, ‘1’ and ‘2’ have certain number of 0’s, then certain number of 1’s and then certain number of 2’s. The condition is that count of each of these 3 symbols should be atleast 1. Two
2 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
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 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 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