- 2072 Chaitra
DFA: even a and odd b
Short answer
Use four states representing (a-count mod2, b-count mod2): q00 (even, even) start, q01 (even, odd) final, q10 (odd, even), q11 (odd, odd). On a, toggle first component; on b, toggle second. Accepts when state is q01.
Construct a DFA over {a, b} accepting strings having an even number of a's and an odd number of b's.
Idea. Remember only the parity of the number of a's and the parity of the number of b's. This gives 4 states: qᵢⱼ means (a-count mod 2 = i, b-count mod 2 = j).
M = (Q, {a, b}, δ, q00, {q01}) with Q = {q00, q01, q10, q11}.
Transition table
| State | a | b |
|---|---|---|
| → q00 | q10 | q01 |
| *q01 | q11 | q00 |
| q10 | q00 | q11 |
| q11 | q01 | q10 |
Reading a flips the first index, reading b flips the second. The final state is q01 (even a's, odd b's).
Diagram
a a
──►(q00) <──────────> (q10)
▲ ▲
b │ │ b
▼ ▼
((q01)) <──────────> (q11)
a a
Every edge is two-way: a joins q00–q10 and q01–q11; b joins q00–q01 and q10–q11. Double circle = final state.
Test
- "aab": q00 →a q10 →a q00 →b q01, final, accepted (2 a's, 1 b).
- "ab": q00 → q10 → q11, not final, rejected (1 a).
- "b": q00 → q01, accepted.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- RE: even a's followed by odd b's · Theory of Computation, chapter 2
- DFA: even 0s and even 1s · Theory of Computation, chapter 2
- DFA for {00}*{11}* language · Theory of Computation, chapter 2
- DFA starts or ends with 01 · Theory of Computation, chapter 2
- Convert ε-NFA (q0..q4) to DFA · Theory of Computation, chapter 2 · asked 2×
- Convert NFA (q0..q4, 0/1) to DFA · Theory of Computation, chapter 2 · asked 2×
- Design FSA accepting odd number of b's · Discrete Structure, chapter 2 · asked 4×
- Design FSA accepting even number of a's · Discrete Structure, chapter 2 · asked 4×
- Handshaking theorem; even number of odd vertices · Discrete Structure, chapter 4 · asked 3×
- Construct FSA accepting reverse language · Discrete Structure, chapter 2