CSC262 · 2080 · 10 marks
What is NFA? How is it different from DFA? How is NFA to DFA conversion done? Convert the following NFA into DFA.
What is NFA? How is it different from DFA? How is NFA to DFA conversion done? Convert the following NFA into DFA.[10]
NFA to DFA: Definition, Differences, Conversion, and Worked Example
Given
The question asks for definitions and a conversion. The specific NFA to be converted was not provided in the question text (the diagram or table is missing), so the worked example below uses this standard NFA:
| State | a | b |
|---|---|---|
| →q₀ | {q₀, q₁} | {q₀} |
| q₁ | ∅ | {q₂} |
| *q₂ | ∅ | ∅ |
Start state: $q_0$; Final state: $q_2$; Alphabet $\Sigma = {a, b}$; no ε-transitions.
Since the original NFA is missing, the theory below is given in full and the conversion is worked on this assumed NFA. In the exam, apply the same subset-construction steps to the NFA printed on your paper.
Solution
1. What is an NFA?
A Non-deterministic Finite Automaton (NFA) is a finite automaton where, for a given state and input symbol, there may be zero, one, or more next states, and ε-moves (transitions without consuming input) are permitted.
Formally, $M = (Q, \Sigma, \delta, q_0, F)$ where:
| Symbol | Meaning |
|---|---|
| $Q$ | Finite set of states |
| $\Sigma$ | Input alphabet |
| $\delta$ | $Q \times (\Sigma \cup {\varepsilon}) \to 2^{Q}$ |
| $q_0$ | Start state |
| $F$ | Set of final states |
A string is accepted if at least one computation path ends in a final state.
2. Difference Between NFA and DFA
| Feature | DFA | NFA |
|---|---|---|
| Transitions per (state, symbol) | Exactly one | Zero, one, or more |
| ε-moves | Not allowed | Allowed |
| Transition function | $\delta: Q \times \Sigma \to Q$ | $\delta: Q \times (\Sigma \cup {\varepsilon}) \to 2^{Q}$ |
| Acceptance | Unique path | Any accepting path |
| States needed | Usually more | Usually fewer |
| Ease of design | Harder | Easier |
| Language class | Regular | Regular (same power) |
Every DFA is an NFA; every NFA has an equivalent DFA.
3. NFA to DFA Conversion (Subset Construction)
- Step 1: DFA start state = $\varepsilon\text{-closure}(q_0)$.
- Step 2: For each DFA state $T$ and symbol $a$: compute $\varepsilon\text{-closure}(\text{move}(T,a))$ = a new DFA state.
- Step 3: Repeat until no new states appear.
- Step 4: A DFA state is final if it contains any NFA final state.
- Step 5: Missing transitions lead to a dead state $\emptyset$.
4. Worked Example (using the assumed NFA above)
Start state: $\varepsilon\text{-closure}(q_0) = {q_0} = A$
State $A = {q_0}$:
- On $a$: ${q_0, q_1} = B$
- On $b$: ${q_0} = A$
State $B = {q_0, q_1}$:
- On $a$: ${q_0, q_1} \cup \emptyset = {q_0, q_1} = B$
- On $b$: ${q_0} \cup {q_2} = {q_0, q_2} = C$
State $C = {q_0, q_2}$:
- On $a$: ${q_0, q_1} \cup \emptyset = {q_0, q_1} = B$
- On $b$: ${q_0} \cup \emptyset = {q_0} = A$
No new states. Final DFA Transition Table:
| DFA State | NFA States | On $a$ | On $b$ | Final? |
|---|---|---|---|---|
| →A | ${q_0}$ | B | A | No |
| B | ${q_0, q_1}$ | B | C | No |
| C | ${q_0, q_2}$ | B | A | Yes (contains $q_2$) |
Start state = $A$; Final state = $C$ (since it contains the NFA final state $q_2$). This DFA accepts all strings over ${a,b}$ ending in "$ab$".
Note on Missing Data
The actual NFA diagram or table intended by the exam was not included in the question, so the worked conversion above uses the assumed NFA. The theory portions (definition, differences, algorithm) are complete and correct regardless.
Check: the transition computations are consistent ($A\to B/A$, $B\to B/C$, $C\to B/A$), and the final state is $C$, the only subset containing $q_2$.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.