- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Construct PDA for accepting L = {anb(2n) | n>=1} U {anbn | n>=1}
A push down automata (PDA) can be formally described as seven tuples
(Q, Σ,S, δ,q0,I,F)
Where,
- Q is finite number of states
- Σ is input alphabet
- S is stack symbol
- Δ is the transition function: QX(Σ∪{e})XSXQ
- q0 is the initial state (q0 belongs to Q)
- I is the initial state top symbol
- F is a set of accepting states
Problem
Construct PDA for L = {anb(2n) | n>=1} ∪ {anbn | n>=1}
Solution
Let
L = {anb(2n) | n>=1}
{anbn | n>=1}
Construct PDA for L= L1 U L2
So, the strings which are generated by the given language L1 are as follows−
L1={abb,aabbbb,aaabbbbbb,….} and
L2= {ab,aabb,aaabbb,….}
L= L1 U L2 = { abb,aabbbb,aaabbbbbb,….} U {ab,aabb,aaabbb,….}
For language L1
In the language a’s are followed by double the b’s
Whenever ‘a’ comes, push ‘a’ two times in the stack and if ‘a’ comes again then do the same.
When ‘b’ comes then pop one ‘a’ from the stack each time. Note that b comes after ‘a’.
Finally at the end of the strings if nothing is left in the STACK then we can declare that language is accepted in the PDA.
For language L2
For language L2 we have to count equal number of a’s and b’s
This can be achieved by pushing a's in STACK and then we will pop a's whenever "b" comes.
Finally, at the end of the strings if nothing is left in the STACK then we can declare that language is accepted in the PDA.
The PDA for the problem is as follows−
Transition functions
The transition functions are as follows −
Step 1: δ(q0, a, Z) = (q1, aZ)
Step 2: δ(q0, a, a) = (q3, aaz)
Step 3: δδ(q1, a, a) = (q1, aa)
Step 4: δ(q1, b, a) = (q2, ε)
Step 5: δ(q2, b, a) = (q2, ε)
Step 6: δ(q2, ε, Z) = (qf1, Z)
Step 7: δ(q3, a, a) = (q3, aaa)
Step 8: δ(q3, b, a) = (q4, ε)
Step 9: δ(q4, b, a) = (q4, ε)
Step 10: δ(q4, ε, Z) = (qf2, Z)
- Related Articles
- Construct PDA for L = {0n1m2(n+m) | m,n >=1}
- Construct a PDA for language L = {0n 1m2m3n | n>=1, m>=1}
- Construct Deterministic PDA for a^n b^n where n>=1
- Construct a Turing Machine for L = {a^n b^n | n>=1}
- Construct Pushdown automata for L = {0m1(n+m)2n | m,n = 0} in C++
- Construct a Turing Machine for language L = {0n1n2n | n≥1}
- Construct Turing machine for L = {an bm a(n+m) - n,m≥1} in C++
- Divide (i) n2 - 2n + 1 by n - 1
- C Program to construct a DFA which accepts L = {aN | N ≥ 1}
- Construct DPDA for anbmc(n+m) n,m≥1 in TOC
- Construct DPDA for a(n+m)bmcn n,m≥1 in TOC
- Construct a DPDA for anb2n n ≥ 1 in TOC
- If \( a=x^{m+n} y^{l}, b=x^{n+l} y^{m} \) and \( c=x^{l+m} y^{n} \), prove that \( a^{m-n} b^{n-1} c^{l-m}=1 . \)
- Design NPDA for accepting the language L = {am b(2m) | m>=1}
- Construct DPDA for anbncm where, n,m≥1 in TOC
