GATE Computer ScienceHardGATE CS (PYQ pattern)

Grammar G: S → ASB | ε; A → aAS | a; B → SbS | A | bb. After eliminating all ε-productions in the standard way (every way of deleting nullable variables from each production is added, A → ε is removed, but S → ε is kept because ε ∈ L(G)), how many productions does the new grammar have in total?

  1. A. 7
  2. B. 10
  3. C. 15
  4. D. 12

Correct answer: D. 12

Only S is nullable. Each production containing S spawns variants with S deleted: S → AB | ASB | ε; A → a | aA | aAS; B → A | Sb | SbS | b | bS | bb, a total of 12 productions.

More Theory of Computation questions

Exams that ask this topic