GATE Computer ScienceHardGATE CS (PYQ pattern)
L = { w ∈ {a, b}* : #ab(w) ≡ #ba(w) (mod 3) }, where #ab and #ba count occurrences of these substrings. How many states does the minimal complete DFA for L have?
- A. 5
- B. 9
- C. 6
- D. 3
Correct answer: A. 5
Occurrences of ab and ba alternate, so #ab − #ba ∈ {−1, 0, 1}; being ≡ 0 (mod 3) means #ab = #ba, i.e. w is empty or starts and ends with the same letter. DFA: start (accepting), 'first a, last a' (accepting), 'first a, last b', 'first b, last b' (accepting), 'first b, last a' — 5 states.
More Theory of Computation questions
- L = { w ∈ {a, b} : |w| ≥ 2 and the 2nd symbol from the left equals the 2nd symbol from the right }. How many states does the minimal…
- L = { w ∈ {a, b} : na(w) ≡ 1 (mod 3) or w contains bb as a substring }. The minimal complete DFA has how many states?
- L = { w ∈ {a, b} : |w| ≥ 2 and the first symbol differs from the last symbol }. How many states does the minimal complete DFA for L have?
- L = { w ∈ {a, b} : w[i] = w[i+3] for every valid index i } (w is periodic with period 3). How many states does the minimal complete DFA…
- L = { w ∈ {a, b} : any two a's in w are separated by at least two b's }. How many states does the minimal complete DFA for L have?
- L = { w ∈ {a, b} : any two a's in w are separated by at least two b's, and w ends with b }. How many states does the minimal complete DFA…