GATE Computer ScienceHardGATE CS (PYQ pattern)

How many strings of length 10 over {a, b} contain aa as a substring but do not contain bb?

  1. A. 152
  2. B. 130
  3. C. 142
  4. D. 89

Correct answer: C. 142

Strings avoiding bb number F(12) = 144; among them only the 2 alternating strings avoid aa too. So 144 − 2 = 142.

More Theory of Computation questions

Exams that ask this topic