DFA for strings ending in abb

December 4, 2026 · Team EasyExamNotes · 1 min read (est.) · 0 comments

Share on WhatsApp

← RGPV CS-501 Theory of Computation May 2023 Solved Paper

Question

Construct a DFA over {a,b} accepting strings with at least one a followed by exactly two b symbols.

Asked in: CS-501 | May 2023 | 2(a)(iii)

Answer

Interpret the wording as requiring suffix abb, allowing any preceding symbols. States track the longest suffix that is a prefix of abb: ε, a, ab, abb respectively. Thus aabb and babb are accepted, while abbb and ab are rejected. If the intended language is only a⁺bb, a separate dead state is needed to reject leading b and any input after the final bb.

The initial state is q0. Accepting states: q3. 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 q1 q2
q2 q1 q3
q3 q1 q0

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.

DFA for strings ending in abb
DFA for strings ending in abb

← RGPV CS-501 Theory of Computation May 2023 Solved Paper

Discussion

Ask a question, share your thoughts or report an error.

Sign in to participate in the discussion.

Join the discussion