GATE Computer ScienceVery hardGATE CS (PYQ pattern)
L = { w ∈ {a, b}* : the substring ab occurs an odd number of times AND the substring ba occurs an odd number of times }. How many states does the minimal complete DFA for L have?
- A. 4
- B. 16
- C. 9
- D. 8
Correct answer: C. 9
#ab − #ba is 0 if w starts and ends with the same letter, ±1 otherwise; so both are odd iff #ab is odd and w begins and ends with the same letter. A DFA must remember the first letter, the last letter and the parity of #ab. The classes have representatives ε, a, b, ab, ba, aba, bab, abab, baba, with aba and bab accepting — 9 states.
More Theory of Computation questions
- How many strings of length 10 over {a, b} have an even number of occurrences of ab AND an even number of occurrences of ba?
- How many strings of length 8 over {a, b} begin with b and contain no aa as a substring?
- Over Σ = {a, b, c}, how many strings of length 6 have an even number of a's and do not contain cc?
- Let L = { aⁿ : n = 1, or n ≥ 3 and (n ≡ 2 (mod 4) or n ≡ 3 (mod 6)) }. How many states does the minimal DFA for this unary language have?
- Let L = { aⁿ : n² ≡ 1 (mod 8) }. How many states does the minimal DFA for L have?
- Let L = { aⁿ : n ≥ 5 and n ≡ 1 (mod 3) }. How many states does the minimal DFA for the concatenation L·L have?