- 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
Explain type 2 grammar with properties
Type 2 grammars are context free grammars (CFG).
All productions are of the form −
A → x — where A is nonterminal, x is a string of nonterminal and terminals,
A context-free grammar is equivalent to a pushdown automaton (PDA) and to context free languages.
Example − Pushdown Automaton (PDA)
Properties
A grammars, G = (V, T, P, S) is said to be context free if the production rule is of the form, A → α .
The transition allows A → ε [i.e., α → ε] where, A is a non terminal symbol α is any terminal or non-terminal symbol.
Here, the left hand side of the transition rule consists of only one non-terminal.
Type 2 grammars are the basis of the syntax of most programming languages such as XML. Properties
The CFG is closed under the following −
Union
Concatenation
Kleene closure
It is not closed under complementation, substitution, reversal.
Example
Consider the production, P ⇒ {S → aSa, S → bSb, S → ε}
Since S → aSa → aaSaa [as S → aSa] → aabSbaa [as S → bSb] → aabbaa [as S → ε]
Thus, S may generate S = {ε, aa, bb, abba, aabbaa, abaaba, …}
Thus, the language is defined as L(G) = {w wR | w ε {a, b}*}
CFG can be handled using the pushdown automaton that uses stack memory to store the symbols.
To Continue Learning Please Login
Login with Google