GATE Computer ScienceVery hardGATE CS (PYQ pattern)

Let L = { w ∈ {a, b}* : n_a(w) = 2·n_b(w) }. The prefix language Pref(L) = { x : xy ∈ L for some y }. How many states does the minimal complete DFA for Pref(L) have?

  1. A. 1
  2. B. 3
  3. C. 2
  4. D. Pref(L) is not regular

Correct answer: A. 1

L is not regular, but every x is a prefix of some member: if d = n_a − 2n_b > 0 append ⌈d/2⌉ b's and, if d is odd, one a first; if d ≤ 0 append −d a's. So Pref(L) = Σ*, accepted by a single accepting state.

More Theory of Computation questions

Exams that ask this topic