Multiple choice

Remove the left recursion from the following grammar. $E \rightarrow Ea|Eb|a|b$

  1. $E \rightarrow aE'|bE';E'\rightarrow aE'|bE'|\epsilon$
  2. $E \rightarrow aE'|bE'|\epsilon;E'\rightarrow aE'|bE'$
  3. $E \rightarrow aE'|bE'|\epsilon;E'\rightarrow aE'|bE'|\epsilon$
  4. <font size="2">N</font>one of these

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To remove left recursion from E → Ea|Eb|a|b: The left-recursive productions are E → Ea and E → Eb. The new non-terminal E' handles the recursion. Original productions become E → aE'|bE'. The E' productions are E' → aE'|bE'|ε. This eliminates immediate left recursion.