- 2073 Chaitra
NDFA importance; two consecutive a or b
Short answer
NFA simplifies design and often uses fewer states than DFA. NFA for aa or bb: start q0, on a go to q0 and q1, on b to q0 and q2. q1 on a to q3, q2 on b to q3; q3 accepts with loops. Example: abba reaches q3; abab rejected.
Why is NDFA important although it is equivalent to a DFA? Design an NDFA which accepts L = {w : w ∈ {a,b}* such that w contains either two consecutive a's or two consecutive b's}.
Why NDFA is important
Although every NFA can be converted to an equivalent DFA, NFAs are useful because:
- Easier design. An NFA can "guess" (for example, where a pattern begins), so it is often much simpler to design than a DFA.
- Fewer states. An NFA with n states may need up to 2ⁿ states as a DFA. For example, "the n-th symbol from the end is 1" needs n + 1 NFA states but 2ⁿ DFA states.
- Constructions are easy. Union, concatenation, star and the conversion from regular expressions (Thompson's construction) are natural with NFAs and ε-moves.
- Theoretical tool. Proofs of closure properties and Kleene's theorem are simpler with NFAs. Nondeterminism is also a key idea for more powerful models: nondeterministic PDAs are strictly more powerful than deterministic PDAs, and nondeterministic Turing machines (which are no more powerful than ordinary TMs) are used to define the class NP.
NFA for strings containing aa or bb
The NFA guesses where the two equal symbols begin.
M = ({q0, q1, q2, q3}, {a, b}, δ, q0, {q3})
| State | a | b |
|---|---|---|
| → q0 | {q0, q1} | {q0, q2} |
| q1 | {q3} | ∅ |
| q2 | ∅ | {q3} |
| *q3 | {q3} | {q3} |
a
┌──► q1 ──a──┐
──► q0 │ ├──► ((q3)) ↻a,b
↻a,b └──► q2 ──b──┘
(q0 -a-> q1, q0 -b-> q2)
(q0 –a→ q1 –a→ q3 detects "aa"; q0 –b→ q2 –b→ q3 detects "bb"; q3 loops on a and b.)
Test
- "abba": q0 →a q0 →b q2 →b q3 →a q3 (final). Accepted, since it contains bb.
- "abab": every path that leaves q0 for q1 or q2 dies on the next symbol (there is no aa or bb), so no path reaches q3 and the string is rejected.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- DFA starts or ends with 01 · Theory of Computation, chapter 2
- DFA avoiding substring 10110 · Theory of Computation, chapter 2
- Difference between DFA and NFA · Theory of Computation, chapter 2 · asked 2×
- Convert NFA (q0,q1,q2) to DFA · Theory of Computation, chapter 2
- DFA for (a(ab)*b)* · Theory of Computation, chapter 2
- DFA: even 0s and even 1s · Theory of Computation, chapter 2
- Define FSM; design FSA with two consecutive a's · Discrete Structure, chapter 2 · asked 4×
- DFA with no three consecutive 0's · Discrete Structure, chapter 2
- Equivalent Y-parameter of parallel two-ports · Electrical Circuit Theory, chapter 7 · asked 3×
- Equivalent Z-parameter of three series two-ports · Electrical Circuit Theory, chapter 7 · asked 3×