- 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 Deterministic PDA for a^n b^n where n>=1
Problem
Construct deterministic push down automata (DPDA) for anbn where n>=1.
Solution
So, the strings which are generated by the given language are as follows −
L={ab,aabb,aaabbb,….}
That is 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 transition diagram is as follows −
Transition Functions
The transition functions are as follows −
δ(q0, a, Z) = (q0, aZ)
δ(q0, a, a) = (q0, aa)
δ(q0, b, a) = (q1, ε)
δ(q1, b, a) = (q1, ε)
δ(q1, ε, Z) = (qf, Z)
Explanation
Step 1 − Let’s take an input string: "aabb".
Step 2 − Scan string from left to right.
Step 3 − First input is 'a' and the rule.
input 'a' and STACK alphabet Z, then
push the input 'a' into STACK : (a,Z/aZ) and state will be q0.
Step 4 − Second input is 'a' and the rule.
input input 'a' and STACK alphabet 'a', then
input push the input 'a' into STACK : (a,a/aa) and state will be q0.
Step 5 − Third input is 'b' and the rule.
input 'b' and STACK alphabet 'a', then
pop STACK with one 'a': (b,a/&epsiloon;) and state will be now q1.
Step 6 − Fourth input is 'b' and the rule.
input 'b' and STACK alphabet 'a' and state is q1, then
pop STACK with one 'a' : (b,a/&epsiloon;) and state will be q1.
Step 7 − We reached the end of the string, the rule.
input ε and STACK alphabet Z, go to final state(qf) : (ε, Z/Z)
- Related Articles
- Construct PDA for L = {0n1m2(n+m) | m,n >=1}
- Construct PDA for accepting L = {anb(2n) | n>=1} U {anbn | n>=1}
- Construct a PDA for language L = {0n 1m2m3n | n>=1, m>=1}
- Construct a Turing Machine for L = {a^n b^n | n>=1}
- Construct DPDA for anbncm where, n,m≥1 in TOC
- Construct DPDA for a(n+m)bmcn n,m≥1 in TOC
- Construct DPDA for anbmc(n+m) n,m≥1 in TOC
- Construct a DPDA for anb2n n ≥ 1 in TOC
- Construct Turing machine for L = {an bm a(n+m) - n,m≥1} in C++
- Construct a Turing Machine for language L = {0n1n2n | n≥1}
- Evaluate: $\frac{a^{2 n+1} \times a^{(2 n+1)(2 n-1)}}{a^{n(4 n-1)}\times(a^{2})^{2 n+3}}$.
- Construct a histogram for the following data:\n
- If $n(A)=30, n(B) = 45, n(A \cup B) = 65$ then find $n(A \cap B)$, $n(A-B)$ and $n(B-A)$.
- Find value of (n^1 + n^2 + n^3 + n^4) mod 5 for given n in C++
- Construct Pushdown automata for L = {0n1m2(n+m) | m,n = 0} in C++
