GATE Computer ScienceModerateGATE CS (PYQ pattern)

In the grammar S → AB | CD; A → aA | BC; B → b | CC; C → AC | c | ε; D → d | DA; E → eE | ε (start S), how many variables are nullable (derive ε)?

  1. A. 5
  2. B. 3
  3. C. 4
  4. D. 2

Correct answer: A. 5

C is nullable directly; B → CC so B is; A → BC so A is; S → AB so S is. E → ε makes E nullable even though it is unreachable (usefulness is a separate question). D is not nullable: both its rules contain d or D itself. Hence S, A, B, C, E: 5.

More Theory of Computation questions

Exams that ask this topic