3.3k views

Which of the following productions eliminate left recursion in the productions given below:

$S \rightarrow Aa \mid b$

$A \rightarrow Ac \mid Sd \mid \epsilon$

1. $S \rightarrow Aa \mid b, A \rightarrow bdA', A' \rightarrow A'c \mid A'ba \mid A \mid \epsilon$
2. $S \rightarrow Aa \mid b, A \rightarrow A' \mid bdA', A' \rightarrow cA' \mid adA' \mid \epsilon$
3. $S \rightarrow Aa \mid b, A \rightarrow A'c \mid A'd , A' \rightarrow bdA' \mid cA \mid \epsilon$
4. $S \rightarrow Aa \mid b, A \rightarrow cA' \mid adA' \mid bdA', A' \rightarrow A \mid \epsilon$
| 3.3k views
0
please do not post wrong question....
0
@ arjun sir this is not the correct question in another pdf it is correct

S-->Aa / b

A-->Ac / Sd / eps

A-->Ac / Aad /bd / eps

A-->bdA' / A'

Finally Grammar is

S-->Aa / b

A-->bdA' / A'

So option B is correct .
by Boss (45.4k points)
selected by
+1 vote

It should be

S-->Aa/d

and

Then for this Option B is correct !
by Loyal (9.9k points)
–3
yes correct :)

To convert Left Recursion to Right Recursion, we do this:

$A\rightarrow Ax|y$  $\equiv$ $A\rightarrow yA'$ and $A'\rightarrow xA'|e$

Here,

$A→Ac∣Sd∣ϵ$ exhibits Left recursion. Expand it.

$A→Ac∣Aad∣bd| e$

Here: identify x's and y's

$x_1 = c$

$x_2 = ad$

$y_1 = bd$

$y_1 = e$

So,  $A\rightarrow bdA'|A'$

$A'\rightarrow cA'|adA'| e$

hence, Option B

by Loyal (7k points)