GATE Computer ScienceHardGATE CS (PYQ pattern)

L = { w ∈ {a, b}* : |w| is even and the last two symbols of w differ }. How many states does the minimal complete DFA for L have?

  1. A. 5
  2. B. 8
  3. C. 4
  4. D. 6

Correct answer: C. 4

Even length means w is a sequence of 2-blocks, and the condition concerns only the last block (ab or ba). States: even position with last block ab/ba (accepting), even position otherwise (start), odd position after a, odd position after b. 4 states — fewer than the 5 needed without the parity condition.

More Theory of Computation questions

Exams that ask this topic