Theory of Computation
Finite Automata
Finite automata give the most predictable TOC marks: know the three machine models, convert NFA to DFA by subset construction, minimize a DFA by table filling, and memorise the state-count patterns for standard languages.
GATE CSE finite automata — DFA, NFA and ε-NFA definitions, ε-closure, subset construction, DFA minimization (table filling / Myhill-Nerode), and minimum-number-of-states MCQs with sample questions, flashcards and drills.
Learning outcomes
- Define DFA, NFA and ε-NFA formally and decide whether a string is accepted by tracing states
- Compute ε-closures and convert an ε-NFA / NFA to an equivalent DFA by subset construction
- Minimize a DFA using the table-filling (Myhill-Nerode) method and count the states of the minimal DFA
- Design DFAs for standard languages (endings, substrings, length and modulo conditions) and give their minimum state counts
DFA, NFA and ε-NFA — definitions
- A finite automaton is a 5-tuple (Q, Σ, δ, q0, F): finite set of states Q, input alphabet Σ, transition function δ, start state q0 ∈ Q and set of accepting (final) states F ⊆ Q.
- DFA: δ : Q × Σ → Q. From every state there is exactly one move on every symbol (a complete DFA). A DFA with n states over an alphabet of k symbols has exactly n·k transitions.
- NFA: δ : Q × Σ → 2^Q. A state may have zero, one or many moves on a symbol. A string is accepted if SOME path ends in a final state.
- ε-NFA: δ : Q × (Σ ∪ {ε}) → 2^Q. The machine may change state without reading input.
- Extended transition: δ*(q, ε) = q and δ*(q, wa) = δ(δ*(q, w), a). L(M) = { w | δ*(q0, w) ∈ F } for a DFA; for an NFA the set δ*(q0, w) must intersect F.
- DFA, NFA and ε-NFA all accept exactly the regular languages. NFAs and ε-NFAs are not more powerful, only easier to design (and possibly exponentially smaller than the equivalent DFA).
- A DFA accepting L becomes a DFA for the complement of L by swapping final and non-final states (the DFA must be complete). This trick does NOT work directly on an NFA.
- Mealy and Moore machines are finite automata with output: a Mealy machine outputs on transitions (output length = input length); a Moore machine outputs on states (output length = input length + 1).
- The empty string ε is accepted exactly when the start state is final (for an NFA: when q0 ∈ F, or for an ε-NFA when ε-closure(q0) contains a final state). A DFA with a single non-final start state and no path to a final state accepts ∅.
- Counting machines: a DFA over k symbols with n states has n·k transitions and 2^n possible choices of final-state set; a complete DFA never “gets stuck”, while a partial DFA (missing moves) implicitly sends the missing moves to a dead state.
- An NFA “dies” on a branch when it has no move; the whole input is rejected only when EVERY branch dies or ends in a non-final state. That is why NFAs are easy to write: you only describe the successful guesses.
- Order of power for finite-state devices: DFA = NFA = ε-NFA = regular expressions = right-linear grammars; a two-way DFA is also only regular. Adding a stack (PDA) or a tape (TM) is what increases power.
- Reading the figure: both machines accept strings over {0,1} that end in 01. The DFA tracks the longest suffix that matches a prefix of “01”; the NFA simply guesses where the final “01” begins.
Formulas to remember
-
DFA: δ(q, a) is a single state; NFA: δ(q, a) ⊆ Q -
Transitions in a complete DFA = |Q| × |Σ| -
NFA with n states ⇒ equivalent DFA with ≤ 2^n states
| Feature | DFA | NFA | ε-NFA |
|---|---|---|---|
| Moves per (state, symbol) | exactly 1 | 0, 1 or many | 0, 1 or many |
| ε-moves | No | No | Yes |
| Language class | Regular | Regular | Regular |
| Acceptance | Unique path ends in F | Some path ends in F | Some path (with ε) ends in F |
| Worst-case DFA size | — | 2^n states | 2^n states |
Worked example
Problem. Does the DFA with states {A, B}, start A, final {B}, δ(A,0)=A, δ(A,1)=B, δ(B,0)=A, δ(B,1)=B accept 0110?
Solution. A —0→ A —1→ B —1→ B —0→ A. The run ends in A, which is not final, so 0110 is rejected. (The DFA accepts strings ending in 1.)
ε-closure and subset construction
- ε-closure(q) is the set of states reachable from q using only ε-moves (always including q itself). ε-closure of a set is the union of the closures of its members.
- ε-NFA → NFA: δ′(q, a) = ε-closure( δ( ε-closure(q), a ) ). The final states are those states whose ε-closure contains an old final state.
- NFA → DFA (subset construction): start state = {q0} (or ε-closure(q0) for an ε-NFA). For each reachable subset S and symbol a, next subset = ∪ δ(q, a) over q ∈ S. A subset is final if it contains at least one NFA final state.
- Build only REACHABLE subsets; the empty subset ∅ acts as the dead (trap) state. Many NFAs give far fewer than 2^n reachable subsets.
- The 2^n blow-up is tight: the language “the n-th symbol from the end is 1” has an n+1 state NFA but needs 2^n states in any DFA.
- Reversal: reversing all arrows of a DFA, swapping start and final states gives an NFA for L^R; the DFA for L^R can need up to 2^n states.
- Procedure to remember: keep a worklist of subsets. Start with {q0}; for each subset and each symbol compute the union of moves; add the result if it is new; stop when the worklist is empty. The number of DFA states is the number of subsets ever discovered.
- A DFA subset is final if it contains AT LEAST ONE NFA final state (not all). If every NFA state is final, every nonempty reachable subset is final.
- Subset construction never creates more than 2^n states but can create exactly 2^n; it never creates fewer than the minimal DFA, so always minimize afterwards if the question asks for the MINIMUM number of states.
- If the NFA is already deterministic (a partial DFA) the subsets are singletons plus ∅, so the construction just completes the DFA with a dead state.
Formulas to remember
-
δ′(q, a) = ε-closure( δ( ε-closure(q), a ) ) -
DFA state = subset of NFA states; |DFA| ≤ 2^|NFA|
| DFA state (subset) | on 0 | on 1 | Final? |
|---|---|---|---|
| {q0} | {q0,q1} | {q0} | No |
| {q0,q1} | {q0,q1} | {q0,q2} | No |
| {q0,q2} | {q0,q1} | {q0} | Yes (q2 final) |
Worked example
Problem. NFA: δ(q0,0)={q0,q1}, δ(q0,1)={q0}, δ(q1,1)={q2}, final q2, start q0. Find the DFA.
Solution. Subset construction gives exactly the three subsets in the table: {q0}, {q0,q1}, {q0,q2}. {q0,q2} is the only final one. The language is “strings ending in 01”, and this 3-state DFA is already minimal.
Worked example — ε-closures and ε-NFA → DFA
- The ε-NFA in the figure accepts a*b*c*: q0 loops on a, q1 loops on b, q2 loops on c, and there are ε-moves q0 → q1 → q2 with q2 final.
- ε-closure(q0) = {q0, q1, q2}, ε-closure(q1) = {q1, q2}, ε-closure(q2) = {q2}. Closure is reflexive and transitive: follow whole CHAINS of ε-moves, not just one step.
- Because ε-closure(q0) contains the final state q2, the empty string is accepted. In the ε-free NFA, q0 becomes a final state.
- ε-free transitions from q0: δ′(q0,a) = closure(δ({q0,q1,q2}, a)) = closure({q0}) = {q0,q1,q2}; δ′(q0,b) = closure({q1}) = {q1,q2}; δ′(q0,c) = closure({q2}) = {q2}.
- The formula applies closure BEFORE reading the symbol (to take free ε-moves), then δ, then closure AGAIN after reading it. Forgetting the second closure is the most common GATE slip.
- In subset construction for an ε-NFA, the DFA start state is ε-closure(q0), and every later subset must also be closed under ε-moves.
- Removing ε-moves does not change the language but may add many transitions; ε-NFAs are mainly a convenience for regex → automaton (Thompson) constructions.
Formulas to remember
-
δ′(q, a) = ε-closure( δ( ε-closure(q), a ) ) -
ε ∈ L ⇔ ε-closure(q0) ∩ F ≠ ∅
| State | ε-closure | Contains a final state? |
|---|---|---|
| q0 | {q0, q1, q2} | Yes (q2) |
| q1 | {q1, q2} | Yes (q2) |
| q2 | {q2} | Yes |
Worked example
Problem. Convert the a*b*c* ε-NFA above to a DFA by subset construction.
Solution. Start = ε-closure(q0) = {q0,q1,q2}. On a → {q0,q1,q2}; on b → {q1,q2}; on c → {q2}. From {q1,q2}: a → ∅, b → {q1,q2}, c → {q2}. From {q2}: a, b → ∅, c → {q2}. The empty set is the dead state (self loop on everything). Final subsets are those containing q2: {q0,q1,q2}, {q1,q2}, {q2}. The DFA has 4 states including the dead state, and all four are distinguishable, so it is already minimal.
DFA minimization — table filling and Myhill-Nerode
- Two states p, q are equivalent (indistinguishable) if for every string w, δ*(p, w) and δ*(q, w) are either both final or both non-final. The minimal DFA merges equivalent states.
- Step 0: remove unreachable states (not reachable from q0). Step 1: mark every pair (final, non-final) as distinguishable. Step 2: repeatedly mark a pair (p, q) if for some symbol a the pair (δ(p,a), δ(q,a)) is already marked. Step 3: unmarked pairs are equivalent — merge them.
- Partition-refinement view: start with {F, Q − F}; split any block whose states go to different blocks on some symbol; stop when no block splits (k-equivalence: 0-equivalence, 1-equivalence, …).
- The minimal DFA is UNIQUE up to renaming of states. Its number of states equals the number of Myhill-Nerode equivalence classes of the language (strings x ~ y iff for all z, xz ∈ L ⇔ yz ∈ L).
- L is regular if and only if the Myhill-Nerode relation has finitely many classes. This also shows that no DFA with fewer states can accept L.
- Minimization applies to DFAs. An NFA has no unique minimal form, so “minimum states of an NFA” questions must be solved by direct design.
- Complementing a complete DFA keeps the number of states unchanged and preserves minimality.
- Worst-case cost: table filling is O(n² · |Σ|) pairs-times-symbols; Hopcroft’s partition refinement achieves O(n |Σ| log n). GATE only asks for the hand method.
- Counting trick: the number of equivalence classes of ≡_L equals the number of states of the minimal DFA, so “how many Myhill-Nerode classes” and “how many states in the minimal DFA” are the same question. For L = strings ending in 01 there are exactly 3 classes: {ε and strings ending in 11}, {strings ending in 0}, {strings ending in 01}.
- Distinguishing string for a non-equivalent pair is found by following the chain of marked pairs backwards; its length is at most n − 2 for an n-state DFA.
| Step | Action |
|---|---|
| 0 | Delete unreachable states |
| 1 | Mark all (final, non-final) pairs |
| 2 | Mark (p, q) if (δ(p,a), δ(q,a)) is marked for some a; repeat until no change |
| 3 | Merge unmarked (equivalent) pairs |
Worked example
Problem. DFA over {0,1}: states q0..q3, final {q3}. δ(q0,0)=q1, δ(q0,1)=q2, δ(q1,0)=q1, δ(q1,1)=q3, δ(q2,0)=q1, δ(q2,1)=q2, δ(q3,0)=q1, δ(q3,1)=q2. Minimize.
Solution. q3 is distinguished from all (only final state). q0 vs q1: on 1 they go to q2 (non-final) and q3 (final) — distinguished. q1 vs q2: on 1 they go to q3 and q2 — distinguished. q0 vs q2: both go to q1 on 0 and q2 on 1, so they are equivalent. Minimal DFA has 3 states: {q0,q2}, {q1}, {q3} (language: strings ending in 01).
Designing DFAs and standard state counts
- Strings ending with a fixed string of length k, or containing a fixed substring of length k: the minimal DFA has k + 1 states (a KMP-style automaton). Strings STARTING with a fixed string of length k need k + 2 states (one dead state).
- Length conditions over Σ: |w| = n needs n + 2 states (n + 1 counting states plus a dead state); |w| ≥ n needs n + 1 states; |w| ≤ n needs n + 2 states; |w| mod n = r needs n states.
- Counting condition (#a(w) mod m = r) needs m states. Two independent conditions multiply: (#a mod m) and (#b mod n) together need m·n states, e.g. “even a’s and even b’s” needs 4.
- Binary numbers divisible by an ODD k (read MSB first): exactly k states (the state is the remainder). Transition: r → (2r + bit) mod k. Start and sole final state is remainder 0. For even k some remainders merge (divisible by 4 needs only 3 states).
- The k-th symbol from the end is a given symbol: NFA with k + 1 states, but the minimal DFA needs 2^k states.
- Unary languages {a^n | n is a multiple of m}: m states in a cycle. For “multiple of 3 or 5” the minimal DFA is a 15-state cycle (period lcm).
- Union / intersection of two DFAs by product construction: m·n states; accept if either (union) / both (intersection) components accept.
Formulas to remember
-
ends with / contains a string of length k ⇒ k + 1 states -
starts with a string of length k ⇒ k + 2 states -
|w| = n ⇒ n + 2 states; |w| ≥ n ⇒ n + 1; |w| mod n = r ⇒ n -
binary divisible by k ⇒ k states -
k-th symbol from the end ⇒ 2^k DFA states, k + 1 NFA states
| Language (over {a,b} or {0,1}) | Min DFA states |
|---|---|
| ends with ab | 3 |
| contains aba | 4 |
| starts with ab | 4 |
| |w| = 3 | 5 |
| |w| ≥ 3 | 4 |
| even number of a’s | 2 |
| even a’s and even b’s | 4 |
| binary number divisible by 5 | 5 |
| third symbol from the end is 1 | 8 |
Worked example
Problem. Minimum states of a DFA over {a, b} accepting all strings that contain aba as a substring.
Solution. States remember the longest suffix matching a prefix of aba: ε, a, ab, aba. The state “aba seen” is a final trap. That is 3 + 1 = 4 states, and all are distinguishable, so the answer is 4.
Worked example — binary numbers divisible by 3
- Read the number MSB first. If the prefix read so far has value v, appending a bit b gives value 2v + b. So the state only needs to remember v mod 3: that is why the DFA has exactly 3 states.
- Transitions: r → (2r + b) mod 3. From 0: bit 0 → 0, bit 1 → 1. From 1: bit 0 → 2, bit 1 → 3 mod 3 = 0. From 2: bit 0 → 4 mod 3 = 1, bit 1 → 5 mod 3 = 2.
- State 0 is both start and final, so ε (value 0) and any string of leading zeros are accepted. Leading zeros never change the remainder (0 → 0 on bit 0).
- The same recipe works for any k: states 0..k−1, δ(r, b) = (2r + b) mod k, start = final = 0. For ODD k all k states are distinguishable, so k is the minimum. For even k some remainders merge: k = 2^m needs only m + 1 states (“ends in m zeros”), and in general k = 2^a · m with m odd needs m + a states.
- Examples of the even case: divisible by 2 → 2 states, divisible by 4 → 3 states (“ends in 00”), divisible by 6 → 4 states (remainders 1 and 4 merge, and so do 2 and 5). GATE questions almost always use odd k such as 3 or 5.
- If the number is read LSB first the machine is a different one; GATE almost always reads MSB first unless the question says otherwise.
- For decimal-digit or base-b inputs the rule generalises to δ(r, d) = (b·r + d) mod k.
Formulas to remember
-
δ(r, bit) = (2r + bit) mod k; start = final = 0 -
divisible by odd k ⇒ k states; divisible by 2^m ⇒ m + 1 states (ends in 0^m)
| State (remainder) | on 0 | on 1 | Role |
|---|---|---|---|
| 0 | 0 | 1 | start, final |
| 1 | 2 | 0 | — |
| 2 | 1 | 2 | — |
Worked example
Problem. Trace 1101 (decimal 13) and 1001 (decimal 9) on the mod-3 DFA.
Solution. 1101: 0 —1→ 1 —1→ 0 —0→ 0 —1→ 1. It ends in state 1 (not final), so 13 is rejected (13 mod 3 = 1). 1001: 0 —1→ 1 —0→ 2 —0→ 1 —1→ 0. It ends in the final state 0, so 9 is accepted.
Worked example — product construction and Myhill-Nerode classes
- Product construction: given DFAs M1 (m states) and M2 (n states) the product has states (p, q). It accepts the INTERSECTION when both components are final, and the UNION when at least one is final. The maximum state count is m·n; the minimal product DFA may be smaller if some pairs merge.
- Independent parity conditions multiply: “even number of a’s” (2 states) with “odd number of b’s” (2 states) gives 4 states, and all four are distinguishable, so the minimal DFA has 4 states.
- Distinguishability check: two states (i, j) and (i′, j′) differ iff some string leads exactly one of them into a final pair. For counters, use the difference of the two counters as the distinguishing string.
- Myhill-Nerode classes for “ends with ab” over {a, b}: (1) strings ending neither in a nor in ab (ε, b, strings ending in bb); (2) strings ending in a; (3) strings ending in ab. Exactly 3 classes ⇒ minimal DFA has 3 states.
- Myhill-Nerode classes for {aⁿbⁿ} are infinite (a, aa, aaa, … are pairwise distinguishable by suitable suffixes b, bb, bbb), so the language is not regular.
- The union of two unary periodic languages {a^n | n mod p = 0} and {a^n | n mod q = 0} with coprime p and q needs lcm(p, q) = p·q states in its minimal DFA (for p = 3, q = 5 that is 15).
Formulas to remember
-
accept(M1 ∩ M2) = F1 × F2; accept(M1 ∪ M2) = (F1 × Q2) ∪ (Q1 × F2) -
|Q| ≤ m · n for the product automaton
| Language over {a, b} | Machine idea | Min DFA states |
|---|---|---|
| even number of a’s | parity of a | 2 |
| even a’s AND odd b’s | product of two parities | 4 |
| a’s ≡ 0 (mod 2) OR b’s ≡ 0 (mod 3) | product, 2 × 3 | 6 |
| ends with ab | KMP-style suffix tracking | 3 |
| {aⁿbⁿ | n ≥ 0} | needs unbounded memory | not regular |
Worked example
Problem. Find the minimum number of states of a DFA over {a, b} accepting strings with an even number of a’s and an odd number of b’s.
Solution. The state must record (parity of a’s, parity of b’s): 2 × 2 = 4 combinations. The start state is (even, even) and the only final state is (even, odd). Any two different pairs are distinguished by appending a suitable string of a’s and b’s that flips exactly the differing parities, so no two states merge. The answer is 4.
GATE exam tricks — counting states fast
- Say the pattern aloud: “ends with / contains / starts with / length / modulo / n-th from the end”, then apply the formula from the previous section instead of drawing the whole DFA.
- Always ask whether a dead state is needed. “Starts with”, “exactly n symbols” and “only a’s followed by b’s” need one; “ends with” and “contains” do not.
- Subset-construction answer choices: the number of REACHABLE subsets is usually less than 2^n — count by building the DFA lazily, not by writing 2^n.
- Complement: swap final / non-final on a complete DFA; state count unchanged. If a question gives a partial DFA, add the dead state first.
- NFA vs DFA statements: “every NFA has an equivalent DFA” TRUE; “ε-NFA is more powerful than NFA” FALSE; “an NFA with n states may need 2^n DFA states” TRUE.
- To test equivalence of two DFA states, run both on strings of increasing length (up to n − 2 symbols suffices for an n-state DFA).
Worked example
Problem. An NFA has 4 states. What is the maximum number of states in its equivalent subset-constructed DFA (including ∅)?
Solution. Every subset of Q can appear: 2^4 = 16 states.
Exam tips
- Memorise the state-count patterns: ends/contains = k + 1, starts = k + 2, length = n + 2, modulo = m, binary divisible by k = k.
- Before minimizing, delete unreachable states; before complementing, make the DFA complete.
- In table filling, mark (final, non-final) pairs first and then propagate one symbol at a time.
- Remember NFA ≡ DFA ≡ ε-NFA in power, but not in size (2^n blow-up).
- For ε-NFA problems compute ε-closures first; the DFA start state is ε-closure(q0).
10 GATE-style MCQs for Finite Automata with full explanations. Attempt each question before revealing the answer.
The minimum number of states in a DFA over {0, 1} accepting all strings that end with 01 is:
Show answer & explanation
Answer: B
The states remember the longest suffix that is a prefix of 01: ε, 0, 01. This is k + 1 = 3 states and they are pairwise distinguishable.
An NFA with n states is converted to a DFA by subset construction. The maximum number of states in the DFA is:
Show answer & explanation
Answer: C
Each DFA state is a subset of the NFA state set, so there are at most 2^n subsets (including ∅).
The minimum number of states in a DFA over {0, 1} that accepts exactly the binary numbers (MSB first) divisible by 5 is:
Show answer & explanation
Answer: B
The state is the current remainder mod 5, with transition r → (2r + b) mod 5. All 5 remainders are reachable and distinguishable.
The minimum number of states in a DFA over {a, b} accepting exactly the strings of length 3 is:
Show answer & explanation
Answer: C
Four states count lengths 0, 1, 2, 3 (the last is final) and one extra dead state absorbs strings longer than 3: n + 2 = 5.
The minimum number of states in a DFA accepting the language {w ∈ {0, 1}* | the third symbol from the right end is 1} is:
Show answer & explanation
Answer: C
The DFA must remember the last 3 symbols, which gives 2³ = 8 distinguishable states. (The NFA needs only 4 states.)
In an ε-NFA, states q0 → q1 and q1 → q2 are connected by ε-transitions only. What is ε-closure(q0)?
Show answer & explanation
Answer: C
ε-closure includes the state itself and everything reachable by ε-moves: q0, then q1, then q2.
Which of the following statements is FALSE?
Show answer & explanation
Answer: B
ε-NFAs, NFAs and DFAs all accept exactly the regular languages. A, C and D are standard true statements.
DFA over {0,1} with states q0, q1, q2, q3; final state q3; δ(q0,0)=q1, δ(q0,1)=q2, δ(q1,0)=q1, δ(q1,1)=q3, δ(q2,0)=q1, δ(q2,1)=q2, δ(q3,0)=q1, δ(q3,1)=q2. The number of states in the minimal equivalent DFA is:
Show answer & explanation
Answer: B
q0 and q2 have identical transitions (0 → q1, 1 → q2) and are both non-final, so they merge. q1 and q3 are distinguishable from the rest, so the minimal DFA has 3 states.
The minimum number of states in a DFA over {a, b} accepting all strings that contain aba as a substring is:
Show answer & explanation
Answer: B
States: ε, a, ab, aba (final trap). k + 1 = 4, and they are pairwise distinguishable.
The minimum number of states in a DFA over {a, b} that accepts strings having an even number of a’s AND an even number of b’s is:
Show answer & explanation
Answer: C
Track (a mod 2, b mod 2): 2 × 2 = 4 states; all four parities are reachable and distinguishable.
Extra page-specific practice beyond the GATE samples. Attempt all 10, then reveal answers to check your reasoning.
The minimum number of states in a DFA over {0, 1} accepting strings with an even number of 0s and an even number of 1s is:
Show answer & explanation
Answer: C) 4
Track the parity of 0s and the parity of 1s: 2 × 2 = 4 states.
The minimum number of states in an NFA over {a, b} that accepts all strings ending with ab is:
Show answer & explanation
Answer: B) 3
q0 loops on a, b; q0 —a→ q1 —b→ q2 (final). Two states are not enough to check the two-symbol suffix, so 3 is minimal.
A complete DFA over an alphabet of 3 symbols has 7 states. The number of transitions is:
Show answer & explanation
Answer: C) 21
A complete DFA has |Q| × |Σ| = 7 × 3 = 21 transitions.
The minimum number of states in a DFA over {a, b} accepting strings with at least 2 a’s is:
Show answer & explanation
Answer: B) 3
States count a’s seen: 0, 1, ≥ 2 (final). b’s do not change the state.
A Moore machine processes an input string of length n. The length of its output is:
Show answer & explanation
Answer: C) n + 1
A Moore machine outputs a symbol for the start state and for each state entered, giving n + 1 outputs. A Mealy machine gives n.
The minimum number of states in a DFA over {a, b} accepting strings that start with ab is:
Show answer & explanation
Answer: B) 4
States: start, “a read”, “ab read” (final, loops on a, b), and a dead state: k + 2 = 4.
The minimum number of states in a DFA over {a, b} accepting strings of length at least 3 is:
Show answer & explanation
Answer: B) 4
States count length 0, 1, 2 and “≥ 3” (final loop): n + 1 = 4.
A complete minimal DFA M has 9 states, of which 4 are final. A DFA for the complement of L(M) will have:
Show answer & explanation
Answer: B) 9 states, 5 final
Complementing swaps final and non-final states: the state count stays 9 and the final states become 9 − 4 = 5.
The class of languages accepted by NFAs (with or without ε-moves) is:
Show answer & explanation
Answer: A) Regular languages
NFAs and ε-NFAs are equivalent to DFAs, so they accept exactly the regular languages.
The minimum number of states in a DFA accepting the unary language {a^n | n is a multiple of 3 or a multiple of 5} is:
Show answer & explanation
Answer: B) 15
The acceptance pattern repeats with period 15 and no smaller period works (period 3 or 5 would classify 5 vs 2 or 3 vs 8 incorrectly), so the minimal DFA is a 15-state cycle.
Topic FAQs
Why does an NFA not accept more languages than a DFA?
Subset construction simulates all NFA paths at once: each DFA state is the set of NFA states the NFA could be in. So every NFA language is regular, even though the DFA may be exponentially larger.
How many states does the minimal DFA for “binary strings divisible by k” need?
For odd k (the usual GATE case, e.g. 3 or 5) exactly k states, one for each remainder 0…k−1, with transition r → (2r + b) mod k and remainder 0 as start and final state. For even k some remainders merge, e.g. divisible by 4 needs only 3 states.
Is the minimal DFA unique?
Yes, up to renaming of states. Its states correspond one-to-one to the Myhill-Nerode equivalence classes of the language.
Does swapping final and non-final states complement an NFA?
No. An NFA accepts if some path accepts, so swapping can accept a word through a different path. Convert to a complete DFA first, then swap.
Hover a card to reveal the answer with a 3D flip. On touch devices, tap the card or use Show answer.