GATE Computer ScienceHardGATE CS (PYQ pattern)

Exactly one of the following strings is NOT in the language of (a + bb)*(b + aa)*. Which one?

  1. A. abbaa
  2. B. bbaba
  3. C. bbbaa
  4. D. aabbb

Correct answer: B. bbaba

In the first part b's come in pairs; in the second part a's come in pairs. bbaba: after bb·a (first part) the remaining ba has a single b, forcing the switch to the second part, which then needs aa — only a single a is left. abbaa = a·bb | aa; bbbaa = bb | b·aa; aabbb = a·a·bb | b.

More Theory of Computation questions

Exams that ask this topic