please do not post wrong question....

The Gateway to Computer Science Excellence

+7 votes

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$

- $S \rightarrow Aa \mid b, A \rightarrow bdA', A' \rightarrow A'c \mid A'ba \mid A \mid \epsilon$
- $S \rightarrow Aa \mid b, A \rightarrow A' \mid bdA', A' \rightarrow cA' \mid adA' \mid \epsilon$
- $S \rightarrow Aa \mid b, A \rightarrow A'c \mid A'd , A' \rightarrow bdA' \mid cA \mid \epsilon$
- $S \rightarrow Aa \mid b, A \rightarrow cA' \mid adA' \mid bdA', A' \rightarrow A \mid \epsilon$

+12 votes

Best answer

+1 vote

Your question is wrong

It should be

S-->Aa/d

and

A--> Ac / Aad/ epsilon

Then for this Option B is correct !

It should be

S-->Aa/d

and

A--> Ac / Aad/ epsilon

Then for this Option B is correct !

0 votes

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**

- All categories
- General Aptitude 1.9k
- Engineering Mathematics 7.5k
- Digital Logic 2.9k
- Programming and DS 4.9k
- Algorithms 4.4k
- Theory of Computation 6.2k
- Compiler Design 2.1k
- Databases 4.1k
- CO and Architecture 3.4k
- Computer Networks 4.2k
- Non GATE 1.4k
- Others 1.4k
- Admissions 595
- Exam Queries 573
- Tier 1 Placement Questions 23
- Job Queries 72
- Projects 18

50,737 questions

57,391 answers

198,589 comments

105,442 users