GATE Computer ScienceVery hardGATE CS (PYQ pattern)

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

  1. A. abba
  2. B. aabba
  3. C. babab
  4. D. abbaa

Correct answer: D. abbaa

The second part (b + ba)* never contains aa, so the final aa of abbaa must lie in the first part (a + ab)*, which would then have to contain the whole string — impossible, because bb never occurs there. The others split: abba = ab | ba, aabba = a·ab | ba, babab = ε | ba·ba·b.

More Theory of Computation questions

Exams that ask this topic