Open In App

ISRO | ISRO CS 2013 | Question 6

Like Article
Like
Save
Share
Report

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
Please comment below if you find anything wrong in the above post


Last Updated : 26 Apr, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads