← RGPV CS-501 Theory of Computation May 2023 Solved Paper
Question
Construct a DFA over {a,b} accepting strings with exactly one a.
Asked in: CS-501 | May 2023 | 2(a)(i)
Answer
q0 means no a has occurred, q1 means exactly one, and q2 means at least two. Examples accepted: a, bab, abb. Examples rejected: ε, bbb, aa. The language is b*ab*.
The initial state is q0. Accepting states: q1. Every state has exactly one outgoing transition for each input symbol, so the machine is deterministic and complete.
| State | a | b |
|---|---|---|
| q0 | q1 | q0 |
| q1 | q2 | q1 |
| q2 | q2 | q2 |
Process the input from left to right and accept only if the final state is accepting. The state meanings establish the invariant after every prefix, proving correctness by induction on input length.

Discussion
Ask a question, share your thoughts or report an error.
Sign in to participate in the discussion.
Join the discussion