Consider the grammar S → AbBaCc | ε A → aAb | ba B → BBC | cb C → cCa | ac…

2020

Consider the grammar

S → AbBaCc | ε
A → aAb | ba
B → BBC | cb
C → cCa | ac

Find the First () of S.

  1. A.

    {a, b, ε}

  2. B.

    {ε}

  3. C.

    {a, ε}

  4. D.

    {a, b, c, ε}

Attempted by 103 students.

Show answer & explanation

Correct answer: A

Given Grammar:

S → AbBaCc | ε
A → aAb | ba
B → BBC | cb
C → cCa | ac

FIRST(A) = { a, b }

Since:
S → AbBaCc | ε

and A does not derive ε,

FIRST(S) = FIRST(A) ∪ { ε }

Therefore,

FIRST(S) = { a, b, ε }

Explore the full course: Niacl Ao It Specialist