StreakPeaked· Practice

ExamsGATETechnical

Which one of the following grammars is free from left recursion?

  1. S → AB A → Aa | b B → c
  2. S → Ab | Bb | c A → Bd | ε B → e
  3. S → Aa | B A → Bb | Sc | ε B → d
  4. S → Aa | Bb | c A → Bd | ε B → Ae | ε

Correct answer: S → Ab | Bb | c A → Bd | ε B → e

Solution

The correct option is free from left recursion because none of its productions lead to a non-terminal that can eventually derive itself as the first symbol in the derivation, thus preventing infinite loops during parsing.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →