GATE Computer ScienceVery hardGATE CS

How many strings of length 12 over {a, b} contain exactly three occurrences of aa as a substring (overlapping occurrences counted separately, so aaa has two)?

  1. A. 806
  2. B. 792
  3. C. 825
  4. D. 840

Correct answer: A. 806

The number of aa occurrences equals the sum over maximal runs of a of (run length − 1). Enumerating all 4096 strings (or a transfer-matrix count over last symbol and occurrence number) gives 806.

More Theory of Computation questions

Exams that ask this topic