GATE Computer ScienceHardGATE CSE · ISRO

How many strings of length at most 6 (the empty string included) over {a, b} belong to L(a*b*a*)?

  1. A. 55
  2. B. 72
  3. C. 127
  4. D. 63

Correct answer: D. 63

For length n the strings are those with at most one maximal block of b's: n(n+1)/2 + 1 of them (with n = 0 giving 1), summed over n = 0..6 gives 63.

More Theory of Computation questions

Exams that ask this topic