Question

Which of these is the correct way to remove left-recursion from this? T -> Xα|δ X...

Which of these is the correct way to remove left-recursion from this?

T -> Xα|δ

X -> Tβ

Options to remove left-recursion from above:

1.

T -> Xα|δ
X -> δβX'
X' -> αβX' | ε

2.

T -> δT'
T' -> XT' | ε
X -> βα

3.

T -> Xα | δ
X -> δβ | Xαβ

4.

T -> δXα | δ
X -> X'X | ε
X' -> αβ

Explain your reasoning for each choice.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer: Choice 2

T -> δT'
T' -> XT' | ε
X -> βα


Explanation: Left Recursion occurs if the production if of the form

A --> Ab | c
Then we write below lines to remove left recursion, we introduce epsilon transition as well
  
A-->cA'  
A' -> b | epsilon

Coming to the above example

T -> Xα|δ
X -> Tβ

We can see that T -> Tβα | δ
Hence we write T -> δT'
Then T' -> XT' | ε (epsilon is introduced )  
and X becomes βα


Thanks, PLEASE UPVOTE. Please comment if there is any concern.,

Add a comment
Know the answer?
Add Answer to:
Which of these is the correct way to remove left-recursion from this? T -> Xα|δ X...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT