- 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 context-free grammar (CFG) consisting of a finite set of grammar rules is a quadruple **(V, T, P, S)** where,

V is a variable (non terminals).

T is a set of terminals.

P is a set of rules, P: V→ (V ∪ T)*, i.e., the left-hand side of the production rules P does have any right context or left context.

S is the start symbol.

**Push down automata**

A push down automata (PDA) consists of the following −

A finite non-empty set of states denoted by Q.

A finite non empty set of input symbols denoted by∑.

A finite non empty set of push down symbol ┌.

A special state is called the initial state denoted by q0.

A special symbol called the initial symbol on the push down store denoted by Z0.

The set of the final subset of Q denoted by F.

The transition function ∂= QX(∑U{^})X┌ to the set of finite subsets of QX┌*.

**Example**

The CFG is as follows −

S->aSa

S->aSa

S->c

**Design a Push down automata to accept the string**

To convert CFG to PDA first write the production rules and then pop.

The rules for the conversion are as follows −

S(q0, ɛ, ɛ)=(q0, ɛ)

S(q0, ɛ,S)=(q0,aSa)

S(q0, ɛ,S)=(q0,bsb)

(q0, ɛ,S)=(q0,c)

Now start pop to convert

S(q0,a,a)=(q1, ɛ)

S(q1,b,b)=(q2, ɛ)

S(q2,c,c)=(q3, ɛ)

**Transition table**

The transition table with regards to converting CFG to PDA is as follows −

Sno | State | Unread input | Stack | Transition |
---|---|---|---|---|

1 | q0 | abbccbba | Ε | 1 |

2 | q0 | abbcbba | S | 1 |

3 | q0 | abbcbba | aSa | 2 |

4 | q1 | bbcbba | Sa | 5 |

5 | q0 | bbcbba | bSba | 3 |

6 | q2 | bcbba | Sba | 6 |

7 | q0 | bcbba | bsbba | 3 |

8 | q2 | cbba | Sbba | 6 |

9 | q0 | cbba | cbba | 4 |

10 | q3 | bba | bba | 7 |

11 | q2 | ba | ba | 6 |

12 | q1 | ɛ | ɛ | 5 |

Whenever you reach the final state by using PDA then we can say that the context free grammar converts into Push down automata.

- Related Questions & Answers
- Convert the given Context free grammar to CNF
- Compare Push down automata and Linear bounded automata
- How to generate the language for context free grammar?
- What is Push down automata in TOC?
- What is context free grammar? Explain with examples
- Explain about CYK Algorithm for Context Free Grammar
- Explain removing unit productions in context free grammar
- Explain non-deterministic push down automata in TOC?
- Generate a CNF for a given context free grammar
- Explain the simplification of context free grammar in TOC
- Explain if the CFG is recognized by Non-deterministic push down automata
- Generate a Context-free grammar for the language L = {anbm| m≠n}?
- What is Context-sensitive Grammar?
- How to convert right linear grammar to left linear grammar?
- How to convert left linear grammar to right linear grammar?

Advertisements