Open In App

Aptitude | GATE CS 1998 | Question 61

Last Updated : 05 Aug, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads