Open In App

Aptitude | GATE CS 1998 | Question 61

Consider the grammar

S →  Aa | b
A → Ac | Sd | ε

Construct an equivalent grammar with no left recursion and with minimum number of production rules.

Answer:
Explanation: Given,



S →  Aa | b
A → Ac | Sd | ε 

We can write this grammar as-

S →  Aa | b
A → Ac | Aad | bd | ε 

After removing left factor we get :-



S → Aa | b
A → A’ | bdA’
A’ → cA’ | adA’ |  ε 

Quiz of this Question

Article Tags :