GATE Computer ScienceHardGATE CS (PYQ pattern)

Over Σ = {a, b, c}, how many strings of length 6 have an even number of a's and do not contain cc?

  1. A. 448
  2. B. 224
  3. C. 365
  4. D. 243

Correct answer: B. 224

Run the 4-state product DFA (parity of a, last symbol c or not) for 6 steps. Let (E, E') be counts with even a's ending in non-c / c, (O, O') likewise. From any state: a flips parity → non-c; b keeps parity → non-c; c keeps parity → c, allowed only from non-c. Iterating from (E, E', O, O') = (1, 0, 0, 0) gives after 6 steps E + E' = 224 (out of 448 strings with no cc).

More Theory of Computation questions

Exams that ask this topic