All mock tests are FREE till 31 December — register to save your progress

Consider the following DFA over Σ = {a, b, c}. Start state q0; final states q2, q3, q4, q5. Transitions (any missing transition goes to a dead state):
Stateabc
→ q0q1––
q1q2q3q4
* q2q2q3q4
* q3q5–q3
* q4q0––
* q5q1––
Which of the following NFAs is valid (equivalent) for the given DFA?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: D. NFA-D: states q0–q3, start q0, final {q2, q3}. q0 –a→ q0, q0 –a→ q1; q1 –b→ q2, q1 –a,c→ q3; q2 –c→ q2, q2 –a→ q0, q2 –a→ q3; q3 –a→ q0

Explanation

In the DFA, after an 'a' from q0 we are in q1; from q1 any single a, b or c is accepted. The NFA in option D captures this: q0 loops on 'a' (guessing where the last useful 'a' starts), q1 –b→ q2 covers the 'b…c*' branch (DFA q3 with its c-loop), and q1 –a,c→ q3 covers the accepting DFA states q2/q4. Checking every string up to length 8 shows option D accepts exactly the same strings as the DFA. Option C fails on 'ab' (q2 must be final), and options A/B fail on strings like 'abac' because the extra a-edge to q4 adds strings the DFA rejects.

More Theory of Computation and Compilers questions