Consider the regular grammar: S → Xa | Ya X → Za Z → Sa | ϵ Y → Wa W → Sa…
2005
Consider the regular grammar: S → Xa | Ya X → Za Z → Sa | ϵ Y → Wa W → Sa where S is the starting symbol, the set of terminals is {a} and the set of non-terminals is {S, W, X, Y, Z}. We wish to construct a deterministic finite automaton (DFA) to recognize the same language. What is the minimum number of states required for the DFA?
- A.
2
- B.
3
- C.
4
- D.
5
Attempted by 71 students.
Show answer & explanation
Correct answer: B
Key insight: derive the set of strings generated by the start symbol S.
From Z → ε | S a we get L(Z) = { ε } ∪ { w a | w ∈ L(S) }.
Then X → Z a gives L(X) = { a } ∪ { w a a | w ∈ L(S) }.
Also W → S a and Y → W a yield L(Y) = { w a a | w ∈ L(S) }.
Since S → X a | Y a, combine the above to get L(S) = { a a } ∪ { w a^3 | w ∈ L(S) }.
Therefore L(S) = { a^{3k+2} | k ≥ 0 } (strings of a whose length is 2 modulo 3).
Minimal DFA reasoning:
Recognizing a unary language that depends only on length modulo 3 requires distinguishing three residue classes (0, 1, 2 mod 3).
A DFA with three states arranged in a 3-cycle on input 'a' can track these residues and accept exactly the residue 2 class.
Two states are insufficient (they can only track parity), and any larger DFA is not minimal.
Conclusion: the minimum number of states required for the DFA is 3.
A video solution is available for this question — log in and enroll to watch it.