GATE Computer ScienceHardGATE CS

Let r = (aab + ab + b)*(ba + a)*. The number of strings of length 7 over {a, b} that are NOT in L(r) is

  1. A. 27
  2. B. 32
  3. C. 24
  4. D. 21

Correct answer: C. 24

Filtering all 128 strings of length 7 by the expression (or complementing its DFA and counting) leaves 24 non-members. The shortest non-member is aaab, and the counts of non-members for lengths 4 to 7 are 1, 3, 9, 24.

More Theory of Computation questions

Exams that ask this topic