GATE Computer ScienceVery hardGATE CS (PYQ pattern)

How many strings of length 10 over {a, b} lie in the language of the regular expression a*b*a*b*?

  1. A. 130
  2. B. 176
  3. C. 56
  4. D. 386

Correct answer: B. 176

A string with r runs matches iff its run pattern fits into a, b, a, b: r ≤ 4 if it starts with a, r ≤ 3 if it starts with b. Strings of length 10 with r runs and a given first letter: C(9, r − 1). Start a: 1 + 9 + 36 + 84 = 130; start b: 1 + 9 + 36 = 46. Total 176.

More Theory of Computation questions

Exams that ask this topic