GATE Computer ScienceHardGATE CS (PYQ pattern)

How many strings of length 7 over {a, b} belong to the language of the regular expression (a + ab + ba)*?

  1. A. 55
  2. B. 38
  3. C. 47
  4. D. 64

Correct answer: C. 47

The regex is ambiguous (aba = a·ba = ab·a), so count distinct strings, not tilings: building the minimal DFA and counting accepted paths of length 7 gives 47; counting tilings would overcount.

More Theory of Computation questions

Exams that ask this topic