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

This question was previously asked in
GATE CS 2016 Official Paper: Shift 2
View all GATE CS Papers >
  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 | ϵ

Answer (Detailed Solution Below)

Option 2 :

S → Ab | Bb | c

A → Bd | ϵ

B → e
Free
GATE CS Full Mock Test
5.4 K Users
65 Questions 100 Marks 180 Mins

Detailed Solution

Download Solution PDF

Method: By option elimination

Option 1:

S → AB

A → Aa | b

B → c

Here, there is a left recursion in “A → Aa”

Option 3:

S → Aa | B

A → Bb | Sc | ϵ

B → d

Since, S → Aa and A → Sc which will result in S → Sca

So, it results in a left recursion.

Option 4:

S → Aa | Bb | c

A → Bd | ϵ

B → Ae | ϵ

Since A → Bd and B → Ae

which results in left recursion, A → Aed or B → Bde

Option 2:

S → Ab | Bb | c

A → Bd | ϵ

B → e

This grammar doesn’t include direct left recursive statement or indirect left recursive statement production.

Latest GATE CS Updates

Last updated on Jan 8, 2025

-> GATE CS 2025 Admit Card has been released on 7th January 2025.

-> The exam will be conducted on 1st February 2025 in 2 shifts.

-> Candidates applying for the GATE CE must satisfy the GATE Eligibility Criteria.

-> The candidates should have BTech (Computer Science). Candidates preparing for the exam can refer to the GATE CS Important Questions to improve their preparation.

-> Candidates must check their performance with the help of the GATE CS mock tests and GATE CS previous year papers for the GATE 2025 Exam.

Get Free Access Now
Hot Links: teen patti lucky teen patti download teen patti joy official teen patti online