Match the following NFAs with the regular expressions they correspond to:
2008
Match the following NFAs with the regular expressions they correspond to:

- A.
P-2, Q-1, R-3, S-4
- B.
P-1, Q-3, R-2, S-4
- C.
P-1, Q-2, R-3, S-4
- D.
P-3, Q-2, R-1, S-4
Attempted by 97 students.
Show answer & explanation
Correct answer: C
Answer mapping: P -> ε + 0(10*1 + 00)*0, Q -> ε + 0(01*1 + 00)*01*, R -> ε + 0(10*1 + 10)*1, S -> ε + 0(10*1 + 10)*10*
Key idea: each automaton accepts either the empty string (the start state is accepting) or a nonempty string that begins with 0 (there is an initial 0 transition from the start). After that initial 0, the two top states form a repeated two-state gadget whose transitions and self-loops define a repeated block (the parenthesized part of the regex). The remaining edges determine the required final suffix (the final 0, 1, 1*, or 10* in each regex).
P: The automaton allows ε, and every nonempty accepted string must start with 0. The two top states allow a repeated block that can be produced either by crossing from left to right and back while using the right-state self-loop on 0 (producing the pattern 10*1) or by taking a direct two-zero path (producing 00). Finally, to end in the accepting top-right state the automaton requires a trailing 0. Putting these parts together gives ε + 0(10*1 + 00)*0, which is the regex labeled as the second expression.
Q: After the initial 0 the repeated gadget here produces blocks corresponding to either a 0 with a run of 1s and another 1 around it (giving 01*1) or the two-zero block 00. The final portion after the repeated blocks allows zero or more trailing 1s (a final 1*), so the overall expression is ε + 0(01*1 + 00)*01*, which is the first listed regex.
R: The repeated two-state gadget for this automaton yields blocks of either 10*1 (cross-and-return using zeros on the right-state loop) or 10 (a short crossing that immediately returns), and the accepting behavior requires a final 1. Combining these gives ε + 0(10*1 + 10)*1, which matches the third listed regex.
S: This automaton’s repeated gadget yields the same block choices as R (10*1 and 10), but its accepting paths allow an ending of 1 followed by any number of 0s (a final 10*). Thus the expression is ε + 0(10*1 + 10)*10*, which matches the fourth listed regex.
Summary check: the distinguishing feature used to pair each NFA with its regex is the required final suffix after the repeated block (final 0, final 1, run of 1s, or 1 followed by any number of 0s), combined with the repeated-block structure (either a crossing that uses a right-state 0* loop producing 10*1 or direct zero-pair blocks 00/10).
A video solution is available for this question — log in and enroll to watch it.