- 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

# Design NPDA for accepting the language L = {am b(2m) | m>=1}

Basically a push down automata (PDA) is as follows −

“Finite state machine+ a stack”

PDA has three components, which are as follows −

- An Input tape.
- A control unit.
- A Stack with infinite size.

A 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)

## Problem

Construct a non-deterministic PDA (NPDA) for accepting the language

L = {a^m b^{2m} | m>=1}.

## Solution

The strings which are generated by this language are −

L = {abb, aabbbb, aaabbbbbb, aaaabbbbbbbb, ......}

The language counts the number of a’s followed by a double number of b’s.

## Explanation

Step 1 − Maintain the order of a’s and b’s.

Step 2 − Construct a stack along with the state diagram.

Step 3 − The count of a’s and b’s is maintained by the stack.

Step 4 − The number of b’s is exactly double of the number of a’s.

Step 5 − We will take 2 stack alphabets:

r = { a, z }

Where,

- r = Set of all the stack alphabet
- z = Start symbol

**Construction of PDA for the given problem**

The PDA is as follows −

## Transition functions

The transition functions for the PDA are as follows −

Design a NPDA, when ‘a’ comes before b then push it in stack and if again ‘a’ comes again push it. Also, when ‘b’ comes then pop one ‘a’ from the stack.

But we do this popping operation for alternate positions of b’s, (for two b’s we pop one ‘a’ and for four b’s we pop two ‘a’).

Finally, at the end if the stack becomes empty then we can say that the string is accepted by the PDA.

- Related Questions & Answers
- Construct a PDA for language L = {0n 1m2m3n | n>=1, m>=1}
- Construct PDA for L = {0n1m2(n+m) | m,n >=1}
- Construct a ∈-NFA for the language L = (a* + b*)
- Design a DFA accepting a language L having number of zeros in multiples of 3
- Construct PDA for accepting L = {anb(2n) | n>=1} U {anbn | n>=1}
- Generate a Context-free grammar for the language L = {anbm| m≠n}?
- Design a push down automaton for L = {wwR | w ∈ {a, b}+}?
- 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}
- Construct ∈-NFA of Regular Language L = b + ba*
- Construct a Turing Machine for L = {a^n b^n | n>=1}
- Construct a Turing Machine for language L = {wwr | w ∈ {0, 1}}
- Design DFA for language over {0,1} accepting strings with odd number of 1’s and even number of 0’s
- Construct ∈-NFA of Regular Language L = 0(0+1)*1
- Construct Pushdown automata for L = {0n1m2(n+m) | m,n = 0} in C++