GATE / CS ARCHIVE

GATE CSE 2002 / QUESTION 21(a)

Four-state NFA for strings ending in abb

Theory of Computation · Finite Automata · Full GATE CSE 2002 paper

GATE 2002, Q21(a) Descriptive
Report issue

Finite Automata

Question 21(a), GATE 2002: Original21(a): Construct a four-state NFA for the language (a|b)*abb over {a,b}. Specify initial/final states and every transition.
Question 21(a), GATE 2002: Original21(a): Construct a four-state NFA for the language (a|b)*abb over {a,b}. Specify initial/final states and every transition.
Tap to enlarge
Answer & solution

Answer: Start q0, accept q3: δ(q0,a)={q0,q1}, δ(q0,b)={q0}, δ(q1,b)={q2}, δ(q2,b)={q3}; all other transitions empty. (no official key was published)

Over alphabet {a,b}, use states q0,q1,q2,q3, with q0 initial and q3 the sole accepting state. q0 has loops on a and b and an additional a-transition to q1; q1 has a b-transition to q2; q2 has a b-transition to q3; q3 has no outgoing transitions. In notation:
q0 --a--> q1 --b--> q2 --b--> q3 (accept), with a,b self-loops at q0.
The loop consumes an arbitrary prefix from (a|b)*, and a nondeterministic branch chooses the a beginning the final abb. Acceptance requires the whole input to end at q3, so the last three letters must be abb. Conversely every string ending in abb has such an accepting path. No epsilon transitions or extra states are needed.

Original paper, page 10