GATE Computer ScienceHardGATE CS (PYQ pattern)

Grammar G: S → AB | ASB | ε; A → a | aA | aAS; B → A | Sb | SbS | b | bS | bb. After eliminating the unit production(s) B → A (copy A's productions to B and drop the unit production), how many productions does the grammar have in total?

  1. A. 12
  2. B. 14
  3. C. 15
  4. D. 13

Correct answer: B. 14

Remove the unit production and add all non-unit productions of A to B: S → ε | AB | ASB; A → a | aA | aAS; B → Sb | SbS | a | aA | aAS | b | bS | bb; total 14.

More Theory of Computation questions

Exams that ask this topic