- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

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(F belongs to Q)

Construct PDA for 0^{n}1^{m}2^{(n+m)} where n,m>=1.

So, the strings which are generated by the given language are as follows −

L={0122,001222,000112222,….}

That is to add the number of 0's and 1's, and that will equal the number of 2's.

So for every 0's and 1's we will pop 2's from the stack.

Let’s count the number of 0's and 1's that total number is equal to the number of 2's.

It can be achieved by pushing 0's and 1's in STACK and then pop 0's and 1's whenever "2" comes.

Finally, at the end of the strings if nothing is left in the STACK then we can say that language is accepted in the PDA.

The **PDA** for the given problem is as follows −

Step 1: δ(q0, 0, Z) = (q0, 0Z)

Step 2: δ(q0, 0, 0) = (q0, 00)

Step 3: δ(q0, 1, 0) = (q0, 10)

Step 4: δ(q0, 1, 1) = (q0, 11)

Step 5: δ(q0, 2, 1) = (q1, ε)

Step 6: δ(q1, 2, 1) = (q1, ε)

Step 7: δ(q1, 2, 0) = (q1, ε)

Step 8: δ(q1, ε, Z) = (qf, Z)

**Step 1** − Let’s take the input string: "00112222” which satisfies the given condition.

**Step 2** − Scan string from left to right.

**Step 3** − For input '0' and STACK alphabet Z, then

Push the input '0' into STACK: (0,Z/0Z) and the state will be q0.

**Step 4** − For input '0' and STACK alphabet 0', then

Push the input '0' into STACK: (0,0/00) and state will be q0.

**Step 5** − For input '1' and STACK alphabet '0', then

Push the input '1' into STACK: (1,0/10) and state will be q0.

**Step 6** − For input '1' and STACK alphabet '1', then

Push the input '1' into STACK: (1,1/11) and state will be q0.

**Step 7** − For input '2' and STACK alphabet '1' and state is q0, then

Pop one '1' as: (2,1/ε) and the state will be q1.

**Step 8** − For input ‘2' and STACK alphabet '1' and state is q1, then

Pop one '1': (2,1/ε) and the state remains q1.

**Step 9** − For input '2' and STACK alphabet '0' and state is q1, then

Pop one ‘0': (2,0/ε) and the state will be q1.

**Step 10** − For input '2’ and STACK alphabet '0' and state is q1, then

Pop one '0' as: (2,0/ε) and the state will remain q1.

**Step 11** − We reached end of the string, for input ε and STACK alphabet Z, then

Go to final state(qf) : (ε, Z/Z)*.

- Related Questions & Answers
- Construct a PDA for language L = {0n 1m2m3n | n>=1, m>=1}
- Construct Pushdown automata for L = {0n1m2(n+m) | m,n = 0} in C++
- Construct PDA for accepting L = {anb(2n) | n>=1} U {anbn | n>=1}
- Construct Turing machine for L = {an bm a(n+m) - n,m≥1} in C++
- Construct DPDA for anbmc(n+m) n,m≥1 in TOC
- Construct Pushdown automata for L = {0(n+m)1m2n | m, n = 0} in C++
- Construct Pushdown automata for L = {0m1(n+m)2n | m,n = 0} in C++
- Construct DPDA for a(n+m)bmcn n,m≥1 in TOC
- Construct Deterministic PDA for a^n b^n where n>=1
- Construct Pushdown automata for L = {a(2*m)c(4*n)dnbm | m,n = 0} in C++
- Construct Pushdown automata for L = {0n1m2m3n | m,n = 0} in C++
- Construct a Turing Machine for L = {a^n b^n | n>=1}
- Construct DPDA for anbncm where, n,m≥1 in TOC
- Sum of even numbers from n to m regardless if n<m or n>m JavaScript
- Design NPDA for accepting the language L = {am b(2m) | m>=1}

Advertisements