- Asked 4/9
- 2072 Asoj · 6 marks
- 2069 Bhadra · 6 marks
Design FSA accepting even number of a's
Short answer
The DFA has states q0 (even a's, start and final) and q1 (odd). On 'a', toggle state; on 'b' remain. Transition table: q0 –a→ q1, –b→ q0; q1 –a→ q0, –b→ q1. It accepts strings over {a,b} with an even number of a's.
Design a Finite State Automata that accepts precisely those strings over {a, b} that contain an even number of a's. Your design should include the proper definition of the finite-state automata, transition table and the transition diagram.
Idea
We only need to remember whether the number of a's read so far is even or odd. So two states are enough: q0 (even number of a's, including zero) and q1 (odd number). Reading a toggles the state; reading b does not change it.
Formal definition
M = (Q, Σ, δ, q0, F) where
- Q = {q0, q1}
- Σ = {a, b}
- Start state q0
- F = {q0} (final state, since the empty string has zero a's, which is even)
- δ is given by the table below.
Transition table
| State | a | b |
|---|---|---|
| → *q0 | q1 | q0 |
| q1 | q0 | q1 |
(→ start state, * final state)
Transition diagram
b b
┌─┐ ┌─┐
↓ │ ↓ │
──→ (( q0 )) ───────a──────→ ( q1 )
↑ │
└──────────a──────────┘
Trace
- "abab": q0 –a→ q1 –b→ q1 –a→ q0 –b→ q0. Ends in q0, accepted (2 a's).
- "baab": q0 –b→ q0 –a→ q1 –a→ q0 –b→ q0, accepted.
- "ab": q0 –a→ q1 –b→ q1, rejected (1 a).
The language is L = {w ∈ {a, b}* : number of a's in w is even} = b*(abab)*. I verified the machine against the count of a's for all strings up to length 8.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Design FSA accepting odd number of b's · Discrete Structure, chapter 2 · asked 4×
- Define FSM; design FSA with two consecutive a's · Discrete Structure, chapter 2 · asked 4×
- Design FSA for strings beginning with baa · Discrete Structure, chapter 2
- Design NFA for strings ending with aba · Discrete Structure, chapter 2
- Regular expression and FSA: at least three b's · Discrete Structure, chapter 2
- Construct FSA accepting reverse language · Discrete Structure, chapter 2