Skip to content
Related Articles

Related Articles

ISRO | ISRO CS 2013 | Question 6
  • Last Updated : 26 Apr, 2018

Which of the following productions eliminate left recursion in the
productions given below:
S → Aa | b
A → Ac | Sd | ε
(A) S → Aa | b
A → bdA’
A’ → A’c | A’ba | A | ε
(B) S → Aa | b
A → A’ | bdA’,
A’ → cA’ | adA’ | ε
(C) S → Aa | b
A → A’c | A’d
A’ → bdA’ | cA | ε
(D) S → Aa | b
A → cA’ | adA’ | bdA’
A’ → A | ε


Answer: (B)

Explanation:

To remove left recursion from the grammar of the
form :  A → Aα | β
We rewrite the production rules as:
           A → βA'
           A'→ αA'| ε

Given Grammar: S → Aa | b
               A → Ac | Sd | ε

after finding indirect left recursion, grammar:

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

here, α = c, ad, β = bd

So, Grammar after removing left recursion = 
               S → Aa | b
               A → A' | bdA'
               A'→ CA'| ada'| ε 

So, option (B) is correct.

Quiz of this Question

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :