GATE / CS ARCHIVE

SUBJECT COLLECTION

Theory of Computation · Finite Automata

59 questions, newest first

GATE CSE has asked 59 questions on Finite Automata (Theory of Computation) from 1991 to 2026, in 39 of the 46 papers; the most recent is in GATE CSE 2026 Set 2. In the last five years it carried 2 marks per 100-mark paper on average, against 1.9 since 2003. Since 2014 the questions have been 11 NAT, 11 MCQ and 5 MSQ. 10 groups of questions here are solved the same way; “One per method” keeps the newest of each.

Browse topics
Show
1 mark · MSQ
Report issue

Possible DFA sizes for a six-state NFA

Finite Automata

Question 26, GATE 2026: An NFA has six states over a finite alphabet. Which values cannot be the number of states of its minimal equivalent DFA: A 32, B 65, C 1, D 128?
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, D

Givens and goal

An NFA has six states over a finite alphabet. Which values cannot be the number of states of its minimal equivalent DFA: A 32, B 65, C 1, D 128?

Approach

Use subset construction for an upper bound and explicit languages to verify the offered feasible values.

Step-by-step solution

1. Subset construction represents each DFA state by a subset of the six NFA states. There are at most 26 = 64 such subsets, including the empty subset. Epsilon closures, if applicable, do not increase this bound.
2. Removing unreachable states and minimizing can only reduce that number. A minimal equivalent DFA therefore cannot require 65 or 128 states, establishing B and D.
3. One state is possible: a six-state NFA can accept every string. For an example with all six states reachable, use a cycle of six accepting states over a one-letter alphabet. Its language is universal and its minimal DFA has one accepting state.
4. To check that 32 is genuinely possible, use the binary language whose fifth symbol from the end is 1. A six-state NFA has one start state that loops on 0 and 1, can nondeterministically guess a 1 as that fifth-from-last symbol, and then traverses four more symbol transitions to an accepting state. A 32-state DFA stores the last five symbols, initially padded with zeros. Any distinct five-bit histories differ in some position j; appending j−1 zeros makes that position the fifth symbol from the end. The two resulting strings have different acceptance outcomes. Thus all 32 histories are distinguishable and the minimal DFA has exactly 32 states.

Common error: An upper bound alone rules out the oversized choices; an explicit witness is useful to verify that the smaller offered values really are possible.

Subset-construction interpretation: after reading a prefix, an NFA may be in several states at once. A deterministic simulator records exactly that reachable subset. With six possible states, each independently present or absent, there are 64 possible records; different prefixes need not reach all of them. This is why 64 is an upper bound, not a claim that every six-state NFA requires 64 DFA states.

Original paper, page 20 · Answer key

2 marks · MSQ
Report issue

Languages of two three-step automata

Finite Automata

Question 47, GATE 2026: Transcribe the source automata as follows; s is the only start/accept state and omitted transitions reject. D1: s−0→u, s−1→v, u−0→w, u−1→z, w−0→s, w−1→s, z−0→s, v−0→t, t−1→s. D2: s−0→u, s−1→v, u−1→w, v−0→t, v−1→t and v−1→w, w−1→s, t−0→s. Select: A equal languages; B L(D1) proper subset of L(D2); C intersection {ε}; D (L(D1)∪L(D2))* is all binary strings of length divisible by 3.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C, D

Givens and goal

Transcribe the source automata as follows; s is the only start/accept state and omitted transitions reject. D1: s−0→u, s−1→v, u−0→w, u−1→z, w−0→s, w−1→s, z−0→s, v−0→t, t−1→s. D2: s−0→u, s−1→v, u−1→w, v−0→t, v−1→t and v−1→w, w−1→s, t−0→s. Select: A equal languages; B L(D1) proper subset of L(D2); C intersection {ε}; D (L(D1)∪L(D2))* is all binary strings of length divisible by 3.

Approach

Enumerate the three-edge returns to the accepting state and exploit unique block boundaries.

Step-by-step solution

1. In D1 the upper paths give 000 and 001 through u,w, and 010 through u,z. The lower path through v,t gives 101. Thus L(D1)={000,001,010,101}*, since every accepting return to s has exactly three symbols.
2. In D2 the path through u,w gives 011. Paths through v,t give 100 and 110, and the path through v,w gives 111. Hence L(D2)={011,100,110,111}*. The two transitions from v on 1 are nondeterministic alternatives, both included.
3. These two block sets are disjoint. A nonempty string of length divisible by three has a unique partition into successive three-bit blocks starting at position 1. Its first block cannot simultaneously belong to both sets, so the languages have no common nonempty word.
4. Both automata accept ε because their start state is accepting. Thus the intersection is exactly {ε}, proving C. The word 000 is accepted only by D1, refuting both equality and the claimed subset in A and B.
5. Together the two block sets contain all eight three-bit words. Kleene star of the union permits concatenations mixing blocks from either automaton, yielding every binary word of length 3k, including k=0. Conversely each concatenated component has length divisible by 3. This proves D.
6. Select C,D. The outer star in D is essential: the plain union need not accept a word whose successive blocks alternate between the two sets. Transitions were verified on the source image.

Original paper, page 33 · Answer key

1 mark · MSQ
Report issue

Bounding DFA states after subset construction

Finite Automata

Question 28, GATE 2025: A regular language L is accepted by an n-state NFA. Which statements are false? A L may also have an NFA with fewer than n states; B L may have a DFA with fewer than n states; C some DFA for L has at most 2^n states; D every DFA for L has more than 2^n states.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: D

Approach: Apply subset construction and distinguish “may” from a guaranteed reduction.
When determinizing an NFA, a DFA state records the set of NFA states that can currently be active. An n-element set has 2n subsets, so the construction uses at most 2n states, including the empty subset if needed. Unreachable subsets can be removed. This proves C and directly contradicts D, making D the false statement.
The NFA in the premise is not required to be minimal. For example, an automaton for all strings can be padded with redundant states although a one-state accepting automaton already recognizes that language. Therefore A and B describe genuine possibilities for a nonminimal supplied NFA.
They do not assert that every n-state NFA can be reduced, nor a strict reduction at n=1 in the conventional nonempty-state model. The exponential bound is an upper bound that can be necessary for some languages, not a claim that every language needs exponentially many DFA states.

Original paper, page 28 · Answer key

2 marks · MSQ
Report issue

Interpreting a suffix-tracking DFA

Finite Automata

Question 50, GATE 2025: A DFA over {a,b} has states q0,q1,q2,q3, start q0 and sole accepting state q3. Transitions on (a,b) are q0→(q0,q1), q1→(q2,q1), q2→(q0,q3), q3→(q2,q1). Which language does it recognize? A words with an even number of b’s; B words containing bab; C words ending in bab; D words avoiding aba.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: C

Approach: Assign each state the longest suffix of the input read so far that is also a prefix of the pattern bab.
The prefixes are ε,b,ba,bab, corresponding respectively to q0,q1,q2,q3. At q0 an a leaves no nonempty matching suffix, while b starts the match. At q1 another b still leaves suffix b, while a extends it to ba. At q2, b completes bab, but a leaves no matching suffix and returns to q0.
After reaching q3, an a leaves suffix ba and returns to q2; a b leaves suffix b and returns to q1. Therefore acceptance records that the current complete word ends in bab, not merely that bab appeared at some earlier position. This proves C.
B fails because baba contains bab but ends at nonaccepting q2. A fails because the empty word has an even b-count but is rejected. D fails because a avoids aba yet is rejected.

Original paper, page 50 · Answer key

2 marks · NAT
Report issue

Finite Automata

Question 60, GATE 2025: Let Σ={1,2,3,4}. For a string x, prod(x) is the product of its symbols modulo 7, with prod(ε)=1. Define L={x:prod(x)=2}. How many states does a minimum DFA for L have?
Tap to enlarge
Answer & solution

Official answer: 6

Step through it (2 parts)

No input symbol is divisible by 7, so a product can never have residue 0. A DFA can keep one of the six nonzero residues 1,…,6 as its state. Start in state 1, use transition δ(r,a)=ra mod 7 for a∈{1,2,3,4}, and accept only state 2. This proves that six states suffice.

To prove minimality, first show all six residues are reachable. Repeated input 3 gives the cycle 1→3→2→6→4→5→1, so every state is reached by some power of the string symbol 3.

Next distinguish two different residues r and s. Nonzero residues modulo the prime 7 have multiplicative inverses. Choose a suffix whose product is t=2r−1 mod 7. Such a suffix exists because powers of 3 realize every nonzero residue. Appending it to a prefix with product r yields rt=2 and is accepted. Appending it to a prefix with product s cannot yield 2: st=rt would imply s=r after cancellation. Thus every pair of reachable states has different residual languages.

By the DFA distinguishability criterion, none of these states can be merged. Exactly six are necessary and sufficient; no seventh zero-residue state is reachable or needed for this alphabet. Answer: 6.

Original paper, page 45 · Answer key

2 marks · MSQ
Report issue

Minimize a DFA and test distinguishability

Finite Automata

Question 50, GATE 2024: A DFA has start state 1 and only accepting state 1. For inputs (0,1), its transitions are: state 1→(2,4); state 2→(3,1); state 3→(1,2); state 4→(1,5); state 5→(4,1). Let n0(w),n1(w) count symbols. Which statements are false? A States 2 and 4 are distinguishable. B States 3 and 4 are distinguishable. C States 2 and 5 are distinguishable. D Every w with n0(w)=n1(w) is accepted.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: B, C

Approach: Group states with the same future acceptance behavior, then interpret the resulting quotient machine.
1. Consider classes C0={1}, C1={2,5}, C2={3,4}. Only C0 accepts. From either member of C1, input 0 leads to C2 and input 1 to C0. From either member of C2, 0 leads to C0 and 1 to C1. From C0, 0 leads to C1 and 1 to C2.
2. This is a stable partition: members of each class have the same accepting status and transition to the same classes for each symbol. Induction on suffix length therefore proves that states 2 and 5 are equivalent, as are states 3 and 4. Claims B and C are false.
3. States 2 and 4 are distinguishable: suffix 1 sends 2 to accepting state 1 but sends 4 to nonaccepting state 5. Thus A is true.
4. Label C0,C1,C2 by residues 0,1,2. A 0 adds 1 modulo 3 and a 1 subtracts 1. Starting at residue 0, the machine accepts exactly when n0−n1 is divisible by 3. Equal counts satisfy this condition, so D is true.
Answer: B and C, because the question asks for false statements.

Original paper, page 31 · Answer key

1 mark · MCQ
Report issue

A two-state parity automaton

Finite Automata

Question 22, GATE 2024: A DFA has start state E (nonaccepting) and state O (accepting). Input 0 loops at either state; input 1 switches E↔O. Which regex represents it? A 0*1(0+10*1)*; B 0*(10*11)*0*; C 0*1(010*1)*0*; D 0(1+0*10*1)*0*. Here + is union.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

Approach: Assign a parity invariant to each state, then check the loop structure in the regex.

1. Derivation. It accepts exactly strings with an odd number of 1s. The initial 0*1 enters the accepting state; each following 0 stays there and each 10*1 makes a round trip through the other state. Therefore0*1(0+10*1)*, option A. B accepts epsilon, C cannot generate 111, and D requires an initial 0, so each differs.

2. Explanation and checks. After any prefix, E means an even number of ones and O means an odd number. In A, the leading 0*1 contributes the first one; each subsequent block contributes either zero ones or exactly two, preserving odd parity. Conversely, after the first one, any remaining ones can be paired, with intervening zeros accommodated by the blocks. The short strings ε, 111 and 1 distinguish B, C and D respectively from the required language.

Original paper, page 16 · Answer key

2 marks · MCQ
Report issue

Split an epsilon-NFA into accepting path families

Finite Automata

Question 41, GATE 2024: NFA states are 1(start),2,3,4,5, with 2 and 5 accepting. Epsilon edges: 1→2,1→4,3→5. Edges labeled 0: 2→3 and 3→2. Edges labeled 1: 4→5 and 5→4. All other transitions absent. Choose regex: A (00)*+1(11)*; B 0*+(1+0(00)*)(11)*; C (00)*+(1+(00)*)(11)*; D 0+ +1(11)*+0(11)*. Here outer + denotes union; 0+ in D means one or more zeros.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

Approach: Enumerate paths ending in each accepting state and track the parity before and after the epsilon jump.

1. Derivation. The initial epsilon choice reaches state2 or 4. State2 accepts an even number of 0s; after an odd number of 0s the machine is in 3 and can take epsilon to accepting 5, after which an even number of 1s returns to 5. The direct state4 branch accepts an odd number of 1s. Thus the language is(00)* + 0(00)*(11)* + 1(11)*. The pure even/odd zero cases together equal 0*, so it can be written 0*+(1+0(00)*)(11)*, option B.

2. Explanation and checks. Staying in the upper component accepts an even zero count; reaching 3 requires an odd zero count and jumping to 5 then permits an even one count. Starting at 4 instead requires an odd one count. A misses the accepted word 0. C wrongly accepts 11 (take ε from (00)* and one pair of ones), whereas the NFA cannot accept pure even-positive ones. D misses ε, which is accepted via 1→2. These witnesses isolate B beyond merely manipulating algebraic expressions.

Original paper, page 28 · Answer key

1 mark · MCQ
Report issue

Finite Automata

Question 14, GATE 2023: A DFA over {0,1} starts in s, accepts only in p, and has transitions s:0→r,1→p; p:0→p,1→q; q:0→r,1→p; r:0→r,1→r. Which expression describes its language? A 1(0*11)*; B 0(0+1)*; C 1(0+11)*; D 1(110*)*.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

The initial 1 enters accepting p; an initial 0 reaches the dead state. At p, 0 loops, while 11 follows p→q→p. A0 at q is rejected, so all accepted suffixes are concatenations of 0 and 11. This gives 1(0+11)*, option C. For example 10 is accepted but not generated by A or D.

Teaching detail. Every accepting run must first consume 1 to reach p. From p there are two ways to return to p without entering the trap: consume a single 0, or consume the pair 11 through q. Any number of these complete return segments is allowed, including none, so the one-letter string 1 is accepted. A suffix ending after the first 1 of a pair stops at nonaccepting q. This run decomposition proves both that every accepted word has the expression's form and that every generated word is accepted.

Original paper, page 11 · Answer key

2 marks · NAT
Report issue

Finite Automata

Question 63, GATE 2023: Find the minimum number of states of a complete DFA over {0,1} accepting strings that never contain three consecutive 1s.
Tap to enlarge
Answer & solution

Official answer: 4

Step through it (2 parts)

Use three accepting states tracking the trailing run of ones of lengths 0, 1, 2, and a rejecting trap after the third consecutive one. A zero resets each nontrap state to run length 0; a one advances the run or reaches the trap. All four states are reachable. The trap differs from the others on the empty suffix. For two run lengths i<j among 0, 1, 2, append 3-j ones: the state j rejects but state i still accepts. Thus all four are pairwise distinguishable and the DFA is minimal.

Teaching detail. Name states q0,q1,q2,dead by the count of trailing 1s until a forbidden run has occurred. On 0, q0,q1,q2 go to q0; on 1 they go to q1,q2,dead respectively. dead loops on both symbols because an earlier occurrence of 111 can never be undone by later zeros. q0,q1,q2 accept, including q0 for ε. Reachability witnesses are ε,1,11,111. A construction alone proves an upper bound of four; the distinguishability argument is required to exclude every possible smaller DFA.

Original paper, page 67 · Answer key

2 marks · MCQ
Report issue

Finite Automata

Question 38, GATE 2021: Which DFA recognizes exactly binary strings ending in 011? Essential transition-table descriptions of the four diagrams: all have states q0,q1,q2,q3, start q0, only q3 accepting. Common transitions: q0 on 0→q1 and on 1→q0; q1 on 0→q1 and on 1→q2; q2 on 0→q1 and on 1→q3. The differing q3 transitions (on 0,on 1) are A (q1,q3); B (q3,q3); C (q1,q2); D (q1,q0).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Label the four states by the longest suffix matching a prefix of 011: ε, 0, 01, 011. Their transitions on(0, 1) are respectively(0,ε),(0, 01),(0, 011),(0,ε). Only the 011 state accepts. These transitions are exactly D. A wrongly accepts 0111, B keeps accepting after arbitrary suffixes, and C accepts 01111 despite its final three symbols being 111.

The invariant is that the state remembers the longest suffix of the input that is also a prefix of the target 011. After reading 0111 there is no nonempty suffix that is such a prefix, so the accepting state's 1-transition must return to q0. After reading 0110, the suffix 0 remains useful, so its 0-transition must go to q1. These two checks distinguish D from the three other diagrams while the invariant proves correctness for arbitrary input lengths.

Original paper, page 32 · Answer key

1 mark · MCQ
Report issue

Finite Automata

Question 9, GATE 2021: A regular language L⊆{0,1}* has a minimal DFA with k states. Which language must also have a k-state minimal DFA? A L−{01}; B L∪{01}; C {0,1}*−L; D L·L.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Complement a complete minimal DFA by exchanging accepting and nonaccepting states. Reachability is unchanged, and every distinguishing suffix still distinguishes the same pair with acceptance reversed. Consequently no states merge and the minimal state count remains k. Thus the complement language, C.

For any states p,q distinguished in L by suffix w, exactly one of their w-runs ends accepting. Flipping all final-state flags preserves that exclusive difference, proving minimality rather than merely giving an upper bound of k states. Completeness matters: a missing transition must first be represented by a dead state before taking a DFA complement.

Original paper, page 59 · Answer key

1 mark · NAT
Report issue

Finite Automata

Question 17, GATE 2021: DFA has start q0, layer-one states u,v, layer-two states p,q and accepting f. Transitions: q0:0→u,1→v; u:0→p,1→q; v:0→p,1→q; p and q:0,1→f; f:0,1→f. Count accepted strings of length 8.
Tap to enlarge
Answer & solution

Official answer: 256

Every input follows one edge through each of the first three layers, reaching the accepting state after exactly three symbols regardless of their values. That state loops on both 0 and 1. Hence every eight-bit string is accepted, giving 2⁸=256.

The machine recognizes all binary strings of length at least three: no earlier state is accepting, and after the third transition it cannot leave f. Thus for any length n≥3 the count is 2n. The two layer-two branches must not be mistaken for missing-input transitions; each accepts both bits on the next step.

Original paper, page 64 · Answer key

2 marks · NAT
Report issue

Finite Automata

Question 51, GATE 2020: L consists of strings over {a,b} whose number of a symbols is divisible by 2 but not by 3. Find the minimum states in a DFA for L.
Tap to enlarge
Answer & solution

Official answer: 6

Step through it (2 parts)

Worked explanation

DFA specification: states q0,…,q5; start q0; accepting q2,q4; δ(qr,a)=q((r+1) mod 6); δ(qr,b)=qr. This is a complete transition graph, with an a-cycle of length six and a b-self-loop at each vertex. Counting zero a symbols is divisible by both 2 and 3, so q0 correctly rejects. For minimality, all qr are reached by ar. The accepting suffix exponents modulo 6 for q0…q5 are respectively {2,4},{1,3},{0,2},{1,5},{0,4},{3,5}. These six sets differ pairwise. Choose an exponent in the symmetric difference to distinguish any two states, proving six inequivalent prefixes and the lower bound.

Derivation and answer

Track the number of a symbols modulo 6. On a increment the remainder, on b leave it unchanged, and accept remainders 2 and 4; these are exactly even counts not divisible by 3. All six states are reachable. From remainder r, accepting suffix lengths modulo 6 form {2-r, 4-r}. These six sets are distinct, so any pair of remainders is distinguished by some suffix ak. Myhill-Nerode therefore requires all 6 states, matching the construction.

Original paper, page 15 · Answer key

2 marks · NAT
Report issue

Minimal DFA for identity permutations

Finite Automata

Question 48, GATE 2019: The alphabet Σ consists of all bijections of {1,...,5} to itself. A word x=x1...xn denotes the composition π(x)=x1∘...∘xn; the empty composition is identity. L contains words whose composition is identity. Find the number of states in a smallest DFA recognizing L.
Tap to enlarge
Answer & solution

Official answer: 120

1. Each alphabet symbol is a permutation of five objects, so there are 5!=120 possible permutations. A prefix matters only through its accumulated composition, suggesting a state for each permutation.
2. Construct that DFA: start in the identity state; if the current state is g and the next symbol is σ, transition to g∘σ. Make identity the sole accepting state. Associativity ensures the stored state after x is exactly π(x), so this 120-state DFA recognizes L.
3. All 120 states are reachable: reading the single alphabet symbol g takes the identity start to g. Hence there are no unreachable states to discard.
4. To prove no states can be merged, take distinct permutations g and h. Append the one-letter suffix g^−1, which is available because inverses are also permutations in Σ. From g this produces g∘g^−1=id and accepts.
5. From h the same suffix produces h∘g^−1. It cannot equal id, since that would imply h=g after composing with g. Thus it rejects, so the two states are distinguishable.
6. Every pair is distinguishable, proving a lower bound of 120 states. Combined with the construction, the minimum is exactly 120. Merely counting symbols would not prove minimality without the reachability and distinguishing-suffix arguments.

Original paper, page 14 · Answer key

1 mark · MCQ
Report issue

NFA to minimal DFA state bound

Finite Automata

Question 6, GATE 2018: An NFA has n states. Its equivalent minimal DFA has k states. Which is always true? A k≥2^n; B k≥n; C k≤n²; D k≤2^n.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

Method

A DFA must remember the entire set of NFA states that could currently be active. There are 2n subsets of an n-element set. Some subsets may be unreachable and some reachable ones may be equivalent, so both reachability pruning and minimization can reduce this bound. There is no general lower bound k≥n: an NFA can contain many redundant states while accepting a language recognized by one DFA state. Some NFA families require exponentially many DFA states, ruling out a universal quadratic bound.

Solution

Subset construction represents each DFA state by a subset of the NFA’s n states, so at most 2n states are needed, including a possible empty subset. Minimization cannot increase that count. Thus k≤2n, D.

Original paper, page 5 · Answer key

2 marks · NAT
Report issue

Order of a unary language

Finite Automata

Question 52, GATE 2018: Define L^0={ε}, L^(i+1)=L^iL; order is least k with L^k=L^(k+1). The unary DFA has accepting start q0, accepting q1, rejecting q2, and transitions q0−0→q1, q1−0→q2, q2−0→q1. Find order of its language.
Tap to enlarge
Answer & solution

Official answer: 2

Method

A path of length 0 accepts, and positive path lengths accept exactly when odd. Concatenation over a unary alphabet adds lengths. Every positive even length 2m can be decomposed as 1+(2m−1), both positive odd, so two language factors suffice for every even length as well. Zero and odd lengths use ε in one factor. To prove the least order, explicitly exclude k=0 and k=1: length 1 distinguishes L0 from L, and length 2 distinguishes L from L².

Solution

The start state is accepting. After one 0 the automaton enters an accepting state alternating with a nonaccepting state, so L1 contains epsilon and precisely the positive odd-length unary words. L1 squared contains every unary word: odd lengths use one odd word and epsilon, while any positive even length is the sum of two positive odd lengths. Hence L1²=0* and L1³=0*. But L10 differs from L1, and L1 differs from L1² because length 2 is absent from L1. The smallest equality index is therefore 2.

Original paper, page 21 · Answer key

1 mark · NAT
Report issue

Finite Automata

Question 22, GATE 2017: For L described by (a+b)*b(a+b) over {a,b}, find the smallest number of states in a deterministic finite automaton accepting L.
Tap to enlarge
Answer & solution

Official answer: 4.0

Our answer: 4

Step through it (2 parts)

1. The expression allows any prefix, then b, then exactly one final symbol. Thus acceptance depends on whether the second-last symbol is b, and words shorter than two are rejected.

2. Use states aa,ab,ba,bb representing the last two symbols, padding the initial short prefix on the left with a. Start at aa; on input z shift xy to yz. Accept ba and bb. All four states are reachable.

3. Two states with different first symbols have different acceptance immediately. If their first symbols agree but second symbols differ, append a; their new first symbols then differ. Every pair is distinguishable, proving the four-state construction minimal.

Original paper, page 11 · Answer key

1 mark · NAT
Report issue

Finite Automata

Question 25, GATE 2017: Find the minimum number of states of a complete DFA accepting L={w1 a w2 | w1,w2∈{a,b}*, |w1|=2, |w2|≥3}.
Tap to enlarge
Answer & solution

Official answer: 8.0

Our answer: 8

Step through it (2 parts)

1. The first two symbols may be arbitrary, the third must be a, and at least three further symbols must follow. Thus accepted strings have length at least 6 and third symbol a.

2. Construct three states for having read 0,1,2 prefix symbols. From the third of these, a enters a suffix-count state and b enters a rejecting dead state. Use four suffix states for 0,1,2,at least 3 symbols after the required a. The last is accepting and loops on both symbols; the dead state also loops on both. Total: 3+4+1=8 states.

3. To prove minimality, the seven nondead states have distinct shortest accepting continuation lengths 6,5,4,3,2,1,0. For two states, a shortest accepting suffix from the one with smaller required length is too short from the other, distinguishing them. The dead state has no accepting continuation at all. All eight are necessary.

Original paper, page 10 · Answer key

2 marks · MCQ
Report issue

Finite Automata

Question 39, GATE 2017: An ε-NFA has transition table (ε,a,b): q0→({q2},{q1},{q0}); q1→({q2},{q2},{q3}); q2→({q0},∅,∅); q3→(∅,∅,{q2}). Compute the extended transition from q2 on aba. A:∅. B:{q0,q1,q3}. C:{q0,q1,q2}. D:{q0,q2,q3}.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

Step through it (4 steps)

1. Begin with ε-closure({q2}), not just {q2}. The ε edge reaches q0, whose ε edge returns to q2, so the starting set is {q0,q2}.

2. Read the first a: only q0 has an a transition, to q1. The ε-closure of q1 adds q2 and q0, giving {q0,q1,q2}. Read b next: q0 goes to q0 and q1 to q3; q2 has no b move. Closing {q0,q3} under ε adds q2, giving {q0,q2,q3}.

3. Read the final a: only q0 contributes q1. Its ε-closure is again {q0,q1,q2}, option C. Applying ε-closure both before input and after every consumed symbol is essential; ε transitions do not consume letters of aba.

Original paper, page 15 · Answer key

1 mark · NAT
Report issue

Finite Automata

Question 16, GATE 2016: How many states does a minimum DFA need for (0+1)*(0+1)(0+1)*, where + denotes union?
Tap to enlarge
Answer & solution

Official answer: 2.0 : 2.0

Our answer: 2

Step through it (2 parts)

The expression Σ*ΣΣ* is exactly the nonempty binary strings. Use a nonaccepting start state and one accepting state reached by either symbol, with both loops on the latter. The empty string differs from every nonempty word, so at least two states are necessary.

The mandatory middle (0+1) contributes at least one symbol, while the starred parts may be empty. The transition table is start:0→accept,1→accept; accept:0→accept,1→accept. The empty suffix distinguishes start from accept because only one is accepting, establishing minimality rather than merely constructing a two-state automaton.

Original paper, page 29 · Answer key

2 marks · MCQ
Report issue

Finite Automata

Question 42, GATE 2016: I: If all NFA states accept, its language is Σ*. II: There exists a regular language A for which A∩B is regular for every language B. A I only; B II only; C both; D neither.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

An NFA can have missing transitions. One accepting start state with no transitions accepts only epsilon, not Σ* for a nonempty alphabet, disproving I. For II choose the regular language A=empty set; its intersection with every B is empty and hence regular. Thus only II, B.

Acceptance by an NFA requires at least one complete run consuming the entire word. An accepting state alone cannot consume an unavailable transition; for the one-state counterexample any nonempty word has no run. II is existential in A but universal in B, so choosing a fixed empty A handles even nonregular or undecidable B at once.

Original paper, page 37 · Answer key

2 marks · NAT
Report issue

Finite Automata

Question 49, GATE 2015: Two complete DFAs over {a,b} each have start nonfinal state 0 and final state 1. M: on a, either state goes to 1; on b, either goes to 0. N: on a, either goes to 0; on b, either goes to 1. Find states in a minimal DFA for L(M)∩L(N).
Tap to enlarge
Answer & solution

Official answer: 1

M records whether the most recent symbol is a; N records whether it is b. Empty input is rejected by both initial states. A nonempty string cannot end in both symbols, so no string belongs to the intersection. Although a mechanical product construction offers up to four states, minimization merges all reachable states into one rejecting sink because every continuation is rejected. A DFA still requires its start state, so the answer is not zero.

Solution: The first DFA accepts exactly strings ending in a, and the second exactly strings ending in b. Their intersection is empty. The minimal complete DFA for the empty language is one nonaccepting state with loops on both symbols, so 1.

Original paper, page 18 · Answer key

2 marks · NAT
Report issue

Finite Automata

Question 45, GATE 2015: How many states does the minimal DFA for(0+1)*(10)have?
Tap to enlarge
Answer & solution

Official answer: 3

Step through it (2 parts)

The language consists of binary strings ending 10. Track no matching suffix, suffix 1, and suffix 10 (accepting). On0 the transitions are q0, q2, q0; on 1 all go to q1. These three states are distinguishable: q2 accepts empty suffix, and suffix 0 distinguishes q1 from q0. Thus 3.

Track the longest suffix that is also a prefix of target 10: empty, 1, and 10. Reading 1 always leaves suffix 1. Reading 0 moves from suffix 1 to accepting 10, and otherwise to empty. These three states suffice. They are also necessary: accepting 10 differs from both nonaccepting states on ε, and suffix 1 differs from empty on continuation 0. This distinguishability proof prevents merely guessing the count from the pattern length.

Original paper, page 41 · Answer key

1 mark · MCQ
Report issue

Finite Automata

Question 32, GATE 2015: Let Σ={0,1} and L be the language of the regular expression Σ*0011Σ*. What is the minimum number of states in a DFA recognizing the complement of L? Options: (A) 4; (B) 5; (C) 6; (D) 8.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. Writing states as matched-prefix lengths 0..4, transitions on (0,1) are 0→(1,0), 1→(2,0), 2→(2,3), 3→(1,4), 4→(4,4). For pattern containment only state 4 accepts; for its complement states 0..3 accept. For any i<j, the suffix completing prefix length j reaches state 4 from j but not from i, proving distinguishability.

2. A DFA tracks the longest suffix matching a prefix of 0011: lengths 0, 1, 2, 3, 4, with 4 an absorbing found-pattern state. These five states are pairwise distinguishable by completing the pattern; flipping accepting states recognizes avoidance of 0011 without changing minimal state count. Thus5, B.

Original paper, page 64 · Answer key

1 mark · MCQ
Report issue

Finite Automata

Question 16, GATE 2014: An NFA starts at q₀ and has accepting state q₃. Its transitions are q₀→q₀ on 0 or 1; q₀→q₁ on 1; q₁→q₂ on 0 or 1; q₂→q₂ on 1; q₂→q₃ on 0 or 1. There are no other transitions. Which states are reachable after reading 0011? A: {q₀,q₁,q₂}. B: {q₀,q₁}. C: {q₀,q₁,q₂,q₃}. D: {q₃}.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

1. Method and setup. Track a set of active states after each symbol; an NFA can follow several transitions at once. Each update uses only the states active before that symbol, so a newly reached q₂ cannot immediately take another transition on the very same input symbol. Acceptance is separate from the requested reachable-state set.

2. Work through the result and its assumptions. Starting at{q0}, the two zeros leave{q0}. The first 1 yields{q0, q1}; the second 1 yields{q0, q1, q2}. No q2 was reached early enough to enter q3. Thus A.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

Finite Automata

Question 36, GATE 2014: A two-state DFA over {0,1} starts in nonaccepting state u and has accepting state v. Transitions are u--0→u, u--1→v, v--0→u, v--1→v. Which expressions describe its language? I: 0*1(1+00*1)*. II: 0*1*1+11*0*1. III: (0+1)*1. Here + is union. A: I,II only. B: I,III only. C: II,III only. D: all three.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

1. Method and setup. Read the invariant of the DFA: after any nonempty input, v means the latest symbol was 1, and u means it was 0. The empty word is rejected. Test the expressions against this exact language, not just a few accepted examples; one accepted word missing from II disproves equivalence.

2. Work through the result and its assumptions. The two-state DFA accepts precisely strings ending 1. Expression III states this directly. In I, an initial 0*1 is followed by repetitions of either 1 or a nonempty block of zeros followed by 1, so it describes exactly the same strings. II omits 0101, which the DFA accepts. Thus I and III, B.

Original paper, page 16 · Answer key

2 marks · MCQ
Report issue

DFA language and equivalent states

Finite Automata

Question 33, GATE 2013: A DFA starts in nonaccepting s; s--1→t and s--0→f. Nonaccepting t loops on 1 and goes to f on 0. Accepting f loops on 0, 1. Which claims are false?1 complement of its language is context-free.2 its language has regex(11*0+0)(0+1)*0*1*.3 this three-state DFA is minimal.4 it accepts every binary string of length≥2. A1, 3; B2, 4; C2, 3; D3, 4.
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The accepting state is reached once a 0 occurs and then loops on both symbols. The language is all binary strings containing at least one 0. Its complement is 1*, hence context-free. The given regular expression describes that same language: its leading component reaches a first 0 and the remaining factors allow arbitrary continuation. The two nonaccepting states have identical future acceptance behavior, so the three-state DFA is not minimal. It does not accept 11. Thus statements 1 and 2 are true and statements 3 and 4 are false. The question asks for the false statements, so the pair 3 and 4 gives option D.

Before the first 0, the machine is in s or t; after the first 0 it stays in accepting f forever. Thus its language is 1*0(0+1)*. The regex’s first factor(11*0+0) is precisely 1*0, and its trailing 0*1* can always be empty, so the expression describes the same language. States s and t accept exactly the same suffixes (those containing a0), hence can be merged. Finally11 is a length 2counterexample to claim 4. Therefore claims 3and4, and only those, are false.

Original paper, page 7 · Answer key

1 mark · MCQ
Report issue

Complement of an epsilon-NFA language

Finite Automata

Question 12, GATE 2012: Over Σ={a}, an epsilon-NFA has states s (initial, nonaccepting), t (accepting), and u (nonaccepting). Its only transitions are s --a--> t, t --ε--> u, u --ε--> s. What is the complement of its accepted language within Σ*?
(A) ∅ (B) {ε} (C) a* (D) {a,ε}.
Tap to enlarge
Your answer
Answer & solution

Official answer: B

The initial state is nonaccepting. A single a reaches the only accepting state, and two epsilon transitions return from that state through the third state to the initial state. Thus each traversal consumes one a and any positive number of a symbols is accepted; epsilon is not. The language is a⁺ and its complement within {a}*=Σ* is {ε}, B.

Check: The initial epsilon-closure is just {s}; no epsilon move leaves s. Therefore the empty input is rejected. After one a reaches t, epsilon moves can return to s, allowing any further a and accepting again at t.

Original paper, page 3 · Answer key

2 marks · MCQ
Report issue

Complete DFA avoiding three consecutive zeros

Finite Automata

Question 46, GATE 2012: Complete a DFA for binary strings in which every length-three substring has at most two zeros (so 000 is forbidden). All strings shorter than three are accepted. States ε (initial),0,1,00,01,10,11 are accepting; q is rejecting. Existing transitions: ε--0→0, ε--1→1, 0--0→00, 0--1→01, 1--0→10, 1--1→11, 01--0→10, 10--1→01, 11--1→11, q--0,1→q. Which list supplies the missing arcs? Each triple means (source,input,target).
(A) (00,1,00),(00,0,01),(01,1,11),(10,0,00),(11,0,10).
(B) (00,0,01),(00,1,q),(01,1,01),(10,0,11),(11,0,01).
(C) (00,1,01),(00,0,q),(01,1,01),(10,0,10),(11,0,01).
(D) (00,1,01),(00,0,q),(01,1,11),(10,0,00),(11,0,10).
Tap to enlarge
Your answer
Answer & solution

Official answer: D

The forbidden length-three substring is exactly 000. The two-symbol states retain the last two symbols until the rejecting sink q is reached. Missing transitions are δ(00, 0)=q, δ(00, 1)=01, δ(01, 1)=11, δ(10, 0)=00, and δ(11, 0)=10. These are precisely table D. Every nonsink state accepts, including the states for strings shorter than three symbols.

Check: Appending 0 to suffix 00 creates forbidden 000, requiring the sink. Appending 1 to 00 leaves suffix 01; appending 1 to 01 leaves 11; appending 0 to 10 leaves 00; appending 0 to 11 leaves 10. This derives every missing arc rather than matching only one table entry.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

Positive multiples of a fixed unary length

Finite Automata

Question 42, GATE 2011: Over alphabet {a}, let L={a^(nk): k>0}, where n is a fixed positive integer. What is the minimum number of states in a DFA recognizing L?

(A) k+1
(B) n+1
(C) 2^(n+1)
(D) 2^(k+1)
Tap to enlarge
Your answer
Answer & solution

Official answer: B

The language is {ank: k>0}, where n is a fixed positive integer; epsilon is excluded. Use a separate nonaccepting start state, then an n-state cycle that records the positive input length modulo n, accepting the residue-zero state. This uses n+1 states. For minimality, the n positive residue classes are pairwise distinguishable by an extension that makes exactly one length divisible by n. The empty prefix is distinguished from a positive multiple of n by the empty suffix, and from each other positive residue by a suffix that completes that residue to a multiple of n. Thus all n+1 classes are necessary, option B.

An explicit construction uses start z and cycle states r0,...,r(n-1). The first a moves z to r(1 mod n); each subsequent a advances the residue by one modulo n; only r0 is accepting. z must reject epsilon whereas r0 accepts it, so the usual n-state modulo counter cannot merge these two states. For n=1 the result is two states, recognizing a+ rather than a*, which also checks the boundary case.

Original paper, page 11 · Answer key

2 marks · MCQ
Report issue

Minimizing a five-state DFA

Finite Automata

Question 45, GATE 2011: DFA D has alphabet {a,b}, start p, accepting states s,t, and transitions p:a→s,b→q; q:a→t,b→r; r:a,b→r; s:a,b→s; t:a,b→t. Which supplied machine is an equivalent minimal DFA? Unlisted states in the alternatives are nonaccepting.

(A) Start p; final s; p:a→s,b→q; q:a→s,b→r; r:a,b→r; s:a,b→s
(B) Start p; finals q,r; p:a,b→q; q:a→r,b→s; r:a,b→r; s:a,b→s
(C) Start p; final q; p:a,b→q; q:a,b→q and also q:b→r; r:a,b→r
(D) Start p; final s; p:a→s,b→q; q:a→s,b→q; s:a,b→s
Tap to enlarge
Your answer
Answer & solution

Official answer: A

The accepting states s and t both loop on a and b, so their right languages are identical and they merge. The other states p, q and r remain distinct: p versus q is distinguished by suffix ba, since p accepts ba while q reaches the dead state; q versus r is distinguished by a; p versus r is also distinguished by a. Any accepting state differs from these nonaccepting states on epsilon. All four resulting classes are reachable. The minimal DFA has classes {p}, {q}, {r}, {s, t}, with p --b--> q --b--> r, r a/b-loops, and a-transitions from p and q to the accepting sink. This is option A.

All five original states are reachable: epsilon reaches p, b reaches q, bb reaches r, a reaches s, and ba reaches t. Initially separate accepting {s,t} from rejecting {p,q,r}; r differs because its a-transition stays rejecting, and then p differs from q because their b-transitions lead to different classes. Alternative B wrongly accepts b, C has two b-transitions from q and is not deterministic, and D accepts bba although the original reaches r on bb and must reject every continuation.

Original paper, page 12 · Answer key

2 marks · MCQ
Report issue

Minimum NFA for all substrings

Finite Automata

Question 41, GATE 2010: Let w be any binary string of length n, and L the set of all substrings of w. What is the minimum number of states in a nondeterministic finite automaton accepting L?
Options: (A) n−1; (B) n; (C) n+1; (D) 2^(n−1).
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

The answer is n+1. For a lower bound, take an accepting computation for w, which has n consuming transitions. If a state repeats at two different consumed-input positions, the nonempty intervening loop can be pumped, accepting a string longer than n. That contradicts the definition of L. Hence at least n+1 states occur. For an upper bound, use states q0,…,qn, all accepting, with q0 initial. For every j=1,…,n add q0 --w[j]--> qj, and for i=1,…,n−1 add qi --w[i+1]--> q(i+1). Every nonempty accepted string follows a contiguous segment of w, and every substring has such a run. Making q0 accepting includes the empty substring. This construction uses one initial state and no epsilon moves; C.

The lower bound applies even when w contains repeated symbols, because the finite language contains w itself but no string longer than n. Pumping a repeated state on that accepting computation would violate this maximum length. In the upper-bound construction, choosing q0→qj chooses the starting position of a substring; continuing along successive positions preserves contiguity, and accepting at any state permits any ending position.

Original paper, page 10

2 marks · MCQ
Report issue

DFA accepting a two-zero suffix

Finite Automata

Question 41, GATE 2009: A DFA starts q0, accepts only q2. On 0, q0→q1→q2→q2; on 1, all states go q0. What does it accept? A strings beginning 0 or 1; B ending 0; C ending 00; D containing 00.
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

The states record zero, one, or at least two consecutive zeros at the end. Every 1 returns to the start state; 0 advances to the accepting state after the second consecutive zero, where further zeros loop. Hence exactly strings ending 00 are accepted, C, rather than all strings that merely contain 00 somewhere.

The state records the length of the current suffix of consecutive zeros, capped at 2. Reading 1 resets that suffix to length 0. Reading a second consecutive 0 reaches q2; additional zeros stay accepting. A string such as 001 contains 00 but ends in 1 and is rejected, separating C from D. A single 0 reaches q1 and is rejected, separating C from B.

Original paper, page 9

2 marks · MCQ
Report issue

Product automaton transition-table discrepancy

Finite Automata

Question 49, GATE 2008: DFA Y has start 1, final 2, and transitions on (a,b): 1→(1,2), 2→(2,1). DFA Z has start 1, final 2: 1→(2,2), 2→(1,1). Which printed table is their intersection product Z×Y? In every offered table P is initial, R is the only final state, and each row below lists its (a,b) destinations.

(A) P:(S,R), Q:(R,S), R:(Q,P), S:(Q,P)
(B) P:(S,Q), Q:(R,S), R:(Q,P), S:(P,Q)
(C) P:(Q,S), Q:(R,S), R:(Q,P), S:(Q,P)
(D) P:(S,Q), Q:(S,R), R:(Q,P), S:(Q,P)
Tap to enlarge
Your answer
Answer & solution

Answer: None (no official key was published)

1. There is no correct option as printed. Let product states be P=(1,1), Q=(1,2), R=(2,2), S=(2,1), in (Z,Y) order. P is initial and R is the sole accepting state.
2. Applying both component transitions gives the rows (a,b): P=(S,R), Q=(R,S), R=(Q,P), S=(P,Q). Option A agrees in its first three rows but prints S=(Q,P), not (P,Q). Options B, C and D send the initial state on b to a nonfinal state, whereas b is accepted by both Y and Z and must be accepted by their intersection product.
3. Thus none represents the product, even after renaming. A would be correct if its final row were repaired. No official key is available to determine how the examination treated the printing defect.

Original paper, page 9

2 marks · MCQ
Report issue

Minimal DFA for two modular counts

Finite Automata

Question 29, GATE 2007: What is the number of states in a minimum DFA for L={w∈{0,1}*: the number of 0s is divisible by 3 and the number of 1s is divisible by 5}?
Options:
(A) 15
(B) 11
(C) 10
(D) 9
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

Step through it (2 parts)

1. Approach. Use a product state (i,j) recording the two remainders. On 0 update i modulo 3; on 1 update j modulo 5. Minimality requires distinguishability, not merely constructing a 15-state DFA.

2. Derivation and interpretation. Track the number of zeros modulo 3 and ones modulo 5, giving 3×5=15 states; accept residue (0,0). Every residue pair is reachable. Any two different pairs are distinguished by appending zeros and ones that bring one pair to (0,0), leaving the other nonzero in at least one coordinate. Thus 15 states are necessary and sufficient, A.

Original paper, page 6

2 marks · MCQ
Report issue

Minimum equivalent DFA size

Finite Automata

Question 75, GATE 2007: A DFA over {a,b} has start state q0, accepting states q1,q2 and nonaccepting states q0,q3. Its complete transition table is: q0: a→q1,b→q0; q1: a→q2,b→q1; q2: a→q1,b→q2; q3: a→q1,b→q2.
How many states does a minimum equivalent DFA have?
Options:
(A) 1
(B) 2
(C) 3
(D) 4
Question 75, GATE 2007: A DFA over {a,b} has start state q0, accepting states q1,q2 and nonaccepting states q0,q3. Its complete transition table is: q0: a→q1,b→q0; q1: a→q2,b→q1; q2: a→q1,b→q2; q3: a→q1,b→q2.
How many states does a minimum equivalent DFA have?
Options:
(A) 1
(B) 2
(C) 3
(D) 4
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Approach. First remove unreachable states, then partition the remaining states by whether any suffix distinguishes their acceptance. q1 and q2 have identical future acceptance behavior even though their names differ.

2. Derivation and interpretation. Delete unreachable q3. States q1 and q2 are equivalent: both accept, b leaves each in the accepting class, and a switches within that class. Merge them. The remaining nonaccepting q0 and accepting merged state are distinguishable by the empty suffix, so two states are necessary and sufficient. Answer B.

Original paper, page 19

2 marks · MCQ
Report issue

Unary lengths generated by three and five

Finite Automata

Question 34, GATE 2006: Over the unary alphabet {1}, what is the smallest number of states in a DFA for (111+11111)*, where + denotes union?
Options:
(A) 3
(B) 5
(C) 8
(D) 9
Tap to enlarge
Your answer
Answer & solution

Answer: D over the unary alphabet (no official key was published)

Step through it (2 parts)

1. The possible lengths are 3a+5b, a,b≥0:0,3,5,6 and all integers≥8. The missing nonnegative lengths are 1,2,4,7.

2. A unary DFA counts lengths 0 through 7, then enters an accepting sink at 8, using 9 states. For any 0≤i<j≤8, append 7−i symbols: the first length becomes 7 and is rejected, while the second exceeds 7 and is accepted.

3. Thus all nine states are distinguishable and D is minimal. This treats the stated expression as a language over{1}; a larger alphabet would require a rejecting sink for other symbols.

4. Teaching check: Lengths 0,3,5,6 and all lengths at least eight are accepted; 1,2,4,7 are rejected. Build states recording exact lengths below eight, followed by one accepting sink. Distinguishability proves this nine-state construction minimal, rather than merely establishing an upper bound.

Original paper, page 5

2 marks · MCQ
Report issue

Language of a DFA

Finite Automata

Question 53, GATE 2005: A deterministic machine over {a, b} starts at nonfinal q0. It has q0−b→q0, q0−a→q1, q1−b→q2, q2−b→q3, with final q3, q3−b→q3 and q3−a→q1; omitted transitions reject. Identify its language. Offered B describes every a being followed by at least two b symbols. Determine whether that wording is exact, including empty and b-only strings. Other choices: A every a followed by exactly two b symbols; C strings containing abb; D strings not containing aa.
Question 53, GATE 2005: A deterministic machine over {a, b} starts at nonfinal q0. It has q0−b→q0, q0−a→q1, q1−b→q2, q2−b→q3, with final q3, q3−b→q3 and q3−a→q1; omitted transitions reject. Identify its language. Offered B describes every a being followed by at least two b symbols. Determine whether that wording is exact, including empty and b-only strings. Other choices: A every a followed by exactly two b symbols; C strings containing abb; D strings not containing aa.
Tap to enlarge
Your answer
Answer & solution

Answer: No exact option; B if at least one a is required (no official key was published)

The start state has a b-loop but is not accepting. An a starts a required pair of b transitions, after which the accepting state permits more b symbols or another a followed by at least two b symbols. Hence the exact language is b*(abb b*)+ = b*(ab{2,})+. All words have at least one a, and every a is followed by at least two consecutive b symbols. Option B omits the at-least-one-a condition and therefore includes ε and every b-only word by vacuous truth, all rejected by the depicted machine. The paper shows the nonaccepting start state. B describes the intended restriction only if the domain excludes b*; there is no literally exact offered answer. Diagram and options continue on page 7.

Trace complete trips from the start to the final state. Initial b symbols can be arbitrary, but they never reach a final state. The first a must be followed by two b transitions to enter q3; additional b symbols may follow, and each later a begins another mandatory two-b segment. Thus at least one ab{2,} block is required. Checking ε or b provides immediate counterexamples to the broad offered description: its universal condition is vacuously true while the machine rejects. Do not silently mark the intended option as an exact language equality.

Original paper, page 6

2 marks · MCQ
Report issue

Product automaton for counts modulo three and two

Finite Automata

Question 86, GATE 2004: A DFA has six states arranged as top row t0,t1,t2 and bottom row b0,b1,b2. Initial and sole accepting state is t0. On 1, each row cycles left-to-right: t0→t1→t2→t0 and b0→b1→b2→b0. On 0, each column toggles tj↔bj. Which condition on (#1,#0) describes the accepted strings?
Options:
(A) Divisible by 3 and 2 respectively
(B) Odd and even respectively
(C) Even and odd respectively
(D) Divisible by 2 and 3 respectively
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. Label each of the three columns by the count of ones modulo 3, from left to right 0,1,2; label upper and lower rows by the count of zeros modulo 2, 0 and 1. Each 1 edge advances one column cyclically without changing row, and each 0 edge toggles the row without changing column.

2. The initial upper-left state is the only accepting state. Hence acceptance requires #1≡0 mod3 and #0≡0 mod2, option A, including the empty string.

3. Teaching check: The two counters are independent: reading 1 changes the column but not the row, and reading 0 changes the row but not the column. Returning to t0 requires both modular counts to return to zero. The empty word is accepted because the start state is accepting.

Original paper, page 12

2 marks · MCQ
Report issue

Counting constrained binary strings accepted by a DFA

Finite Automata

Question 50, GATE 2003: A DFA over {0,1} has states q0 (start), q1, q2 and q3 (the only accepting state). Transitions: q0 on 1→q0 and 0→q1; q1 on 1→q0 and 0→q2; q2 on 0→q2 and 1→q3; q3 on either symbol→q3. Let S contain seven-bit strings whose first, fourth and last bits are 1. How many strings of S are accepted?
A. 1  B. 5  C. 7  D. 8
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Reaching q2 requires two consecutive zeros; after reaching q2 a later 1 enters the absorbing accepting state q3.
2. Strings of S have form 1xy1zw1, leaving four free bits and 16 total strings. Adjacent zeros can occur only as xy=00 or zw=00, because fixed 1s separate the blocks.
3. Fixing xy=00 leaves four choices for zw; fixing zw=00 leaves four choices for xy. The string 1001001 is counted twice. Inclusion–exclusion yields 4+4−1=7, so C.

Solution: The DFA accepts precisely strings that contain two consecutive zeros followed later by a one. With positions 1,4,7 fixed to one, a qualifying pair of zeros must occupy positions 2–3 or 5–6, and the following fixed one guarantees acceptance. Of the 16 assignments to the four free bits, four have the first zero pair, four have the second, and one has both. Inclusion–exclusion gives 4+4−1=7 accepted strings, option C.

Original paper, page 7

2 marks · MCQ
Report issue

Flipping final states in an NFA

Finite Automata

Question 55, GATE 2003: An NFA M over {0,1} has states p (start), q and r (only final). Transitions are p→q on 0 or 1; q→p on 0; q→q on 0 or 1; p→r on 1; q→r on 0; r→q on 0. There are no other transitions. Let L=L(M). M1 is obtained by making r nonfinal and p,q final, and L1=L(M1). Which statement is true?
A. L1={0,1}*−L
B. L1={0,1}*
C. L1⊆L
D. L1=L
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

1. Since p is final in M1, ε is accepted.
2. For any nonempty word, choose p→q on its first symbol. Then choose the 0/1 loop at q for every remaining symbol. This accepting run exists for every word.
3. Therefore L1 is the universal binary language, B. In particular ε∈L1 but ε∉L, ruling out C and D. Since 1∈L as well as L1, they are not complements, ruling out A. NFA acceptance is existential over runs, which is why simply flipping finals fails as a complement construction.

Solution: After the flip, the initial left state and the upper-right state are accepting. The empty string is accepted at the initial state. For every nonempty binary string, choose the transition from the initial state to the upper-right state on its first symbol and then use that state’s 0/1 loop for the suffix. Therefore the new language is all of {0,1}*, option B. Flipping final states complements a complete DFA, not a general NFA.

Original paper, page 8

2 marks · MCQ
Report issue

Automaton for lengths divisible by three

Finite Automata

Question 2.13, GATE 2002: How many states does the smallest finite automaton need to accept all strings whose lengths are divisible by 3?
(A) 2; (B) 3; (C) 4; (D) 5.
Tap to enlarge
Your answer
Answer & solution

Answer: B (no official key was published)

Step 1: Explain both construction and minimality.

Step 2: Label states 0,1,2 and send each state to its successor modulo 3 for every input symbol. Start and accept at 0. To distinguish residues r≠s, append a word of length(3−r) mod3: the state r accepts afterward and s does not. Thus no two residue states can be merged in a deterministic automaton.

Conclusion: Use three states for the input length modulo 3, advance the residue on every symbol, and accept residue 0. The three residues are distinguishable: append a length that brings one chosen residue to 0; it does not bring a different residue to 0. Thus a minimal DFA has 3 states, B, over a nonempty alphabet.

Original paper, page 5

Descriptive
Report issue

Four-state NFA for strings ending in abb

Finite Automata

Question 21(a), GATE 2002: Original21(a): Construct a four-state NFA for the language (a|b)*abb over {a,b}. Specify initial/final states and every transition.
Question 21(a), GATE 2002: Original21(a): Construct a four-state NFA for the language (a|b)*abb over {a,b}. Specify initial/final states and every transition.
Tap to enlarge
Answer & solution

Answer: Start q0, accept q3: δ(q0,a)={q0,q1}, δ(q0,b)={q0}, δ(q1,b)={q2}, δ(q2,b)={q3}; all other transitions empty. (no official key was published)

Over alphabet {a,b}, use states q0,q1,q2,q3, with q0 initial and q3 the sole accepting state. q0 has loops on a and b and an additional a-transition to q1; q1 has a b-transition to q2; q2 has a b-transition to q3; q3 has no outgoing transitions. In notation:
q0 --a--> q1 --b--> q2 --b--> q3 (accept), with a,b self-loops at q0.
The loop consumes an arbitrary prefix from (a|b)*, and a nondeterministic branch chooses the a beginning the final abb. Acceptance requires the whole input to end at q3, so the last three letters must be abb. Conversely every string ending in abb has such an accepting path. No epsilon transitions or extra states are needed.

Original paper, page 10

Descriptive
Report issue

Four-state DFA for strings ending in abb

Finite Automata

Question 21(b), GATE 2002: Original21(b): Construct a four-state DFA for the same language (a|b)*abb; specify all transitions and accepting state.
Question 21(b), GATE 2002: Original21(b): Construct a four-state DFA for the same language (a|b)*abb; specify all transitions and accepting state.
Tap to enlarge
Answer & solution

Answer: Start q0, accept q3. On (a,b): q0→(q1,q0); q1→(q1,q2); q2→(q1,q3); q3→(q1,q0). (no official key was published)

Step through it (2 parts)

Use state qj to record the length j of the longest suffix of the input seen so far that is also a prefix of abb. The four represented suffixes are empty, a, ab, abb. Start at q0 and accept only q3. The transition table is:
State | a | b
q0 | q1 | q0
q1 | q1 | q2
q2 | q1 | q3
q3 | q1 | q0
For example, reading a after ab or abb leaves suffix a, while reading b after abb leaves no nonempty suffix that begins abb. This invariant proves that q3 is reached at end exactly for strings ending in abb. All transitions are defined and exactly four states are used.

Original paper, page 10

1 mark · MCQ
Report issue

Worst-case NFA to DFA state blowup

Finite Automata

Question 1.6, GATE 2001: For an N-state NFA, determine the maximum possible size of an equivalent minimized DFA. Listed expressions are N², 2^N, 2N, and N!. The reproduced wording uses “maximum … at least”; distinguish worst-case size from the size for every individual NFA.
Tap to enlarge
Your answer
Answer & solution

Answer: B for the tight worst-case bound (no official key was published)

Step 1: Subset construction represents a DFA state by a subset of the N NFA states. There are at most 2N such subsets, and minimization cannot increase that number.

Step 2: This bound can be attained when the alphabet is unrestricted. Start at q0, make q0 accepting, and include symbols that map q0 to each chosen subset S. Include test symbols bi that map only qi to q0 and all other states to the empty set. Every subset is reachable, and bi distinguishes two subsets that differ in whether they contain qi. Thus all 2N subsets are inequivalent.

Conclusion: The maximum over N-state NFAs is 2N, B. This is not a claim that every particular NFA requires 2N states. The source phrase “maximum … at least” is imprecise; the tight worst-case reading is used.

Original paper, page 1

2 marks · MCQ
Report issue

DFA tracking two independent modular counts

Finite Automata

Question 2.5, GATE 2001: Find the minimum DFA size over {a,b} accepting exactly strings whose a-count is divisible by 6 and b-count by 8. Options: 8,14,15,48.
Question 2.5, GATE 2001: Find the minimum DFA size over {a,b} accepting exactly strings whose a-count is divisible by 6 and b-count by 8. Options: 8,14,15,48.
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Step 1: Store a pair(i,j), where i is the number of a symbols modulo 6 and j the number of b symbols modulo 8. Reading a increments only i; reading b increments only j. Accept(0,0). This constructs 6·8=48 states.

Step 2: Every pair is reached by ai bj. For two distinct pairs, append a number of a and b symbols that brings the first pair to(0,0). The second pair retains a nonzero difference in at least one residue and rejects. Thus all pairs are distinguishable.

The construction is minimal, giving 48, D, not the sum 6+8.

Original paper, page 4

Descriptive
Report issue

DFA detecting substring baab

Finite Automata

Question 5(a), GATE 2001: Alphabet {a,b}; accept precisely strings containing baab as a contiguous substring.

Task: Construct a DFA for this language.
Question 5(a), GATE 2001: Alphabet {a,b}; accept precisely strings containing baab as a contiguous substring.

Task: Construct a DFA for this language.
Tap to enlarge
Shared context

Alphabet {a,b}; accept precisely strings containing baab as a contiguous substring.

Answer & solution

Answer: Start q0; accepting q4. Transitions on (a,b): q0→(q0,q1), q1→(q2,q1), q2→(q3,q1), q3→(q0,q4), q4→(q4,q4). (no official key was published)

Step through it (2 parts)

1. Use states to remember the longest suffix of the input read so far that is also a prefix of baab: q0 remembers ε, q1 remembers b, q2 remembers ba, and q3 remembers baa. q4 means the complete substring has already occurred.

2. From q0, a contributes no matching prefix and b starts one: δ(q0,a)=q0, δ(q0,b)=q1. From q1, a extends b to ba, while another b starts a fresh b: δ(q1,a)=q2, δ(q1,b)=q1.

3. From q2, a extends ba to baa; b leaves the suffix b. Thus δ(q2,a)=q3, δ(q2,b)=q1. From q3, b completes baab and a destroys every nonempty matching suffix: δ(q3,b)=q4, δ(q3,a)=q0.

4. Both transitions from q4 loop to q4, since later symbols cannot remove an occurrence already seen. Set start q0 and accepting set {q4}. The trace baab is q0→q1→q2→q3→q4; baa alone ends in nonaccepting q3.

Original paper, page 7

Descriptive
Report issue

DFA for odd counts of both letters

Finite Automata

Question 5(b), GATE 2001: Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.

Task: Construct a DFA for this language.
Question 5(b), GATE 2001: Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.

Task: Construct a DFA for this language.
Tap to enlarge
Shared context

Alphabet {a,b}; accept strings with an odd number of a symbols and an odd number of b symbols.

Answer & solution

Answer: Four parity states EE, OE, EO, OO; start EE, sole accepting OO. a toggles first component, b toggles second. (no official key was published)

Step through it (2 parts)

1. Only the two parities matter, so use states (parity of a count, parity of b count). The empty string has counts zero and zero, making EE the start state.

2. Reading a increments only the a count and toggles its parity. Reading b toggles only the b parity. Complete transition table on (a,b): EE→(OE,EO); OE→(EE,OO); EO→(OO,EE); OO→(EO,OE).

3. Mark only OO accepting. By induction on the processed prefix, the stored pair equals its two actual count parities: the base is EE and every transition applies the correct single parity toggle.

4. Therefore a string is accepted exactly when both counts are odd. For instance ab ends in OO, whereas aab ends in EO and is rejected.

Original paper, page 7

2 marks · MCQ
Report issue

What a two-state unary DFA need not imply

Finite Automata

Question 2.8, GATE 2000: A unary regular language has a minimal two-state automaton. Must it be the odd-length language,the even-length language,a*,or one of the two parity languages?
Tap to enlarge
Your answer
Answer & solution

Answer: No listed conclusion follows without an additional restriction (no official key was published)

Step 1: Consider L=a+, the nonempty unary strings. A minimal complete DFA has a nonaccepting start state that transitions on a to an accepting state with an a self-loop. The two states are distinguishable by ε.

Step 2: This L contains both odd and positive even lengths but excludes ε, so it is neither parity language nor a*. It satisfies the two-state premise and refutes all four mandatory claims.

If the two reachable states were additionally required to form a cycle, exactly one would accept in a minimal two-state DFA, yielding parity and option D. The source does not state that restriction. Strong connectivity cannot be assumed from minimality.

Original paper, page 4

Descriptive
Report issue

Minimal automaton for alternating bits

Finite Automata

Question 7(a), GATE 2000: Alphabet {0,1}; accept exactly the strings containing neither 00 nor 11 as a substring.

Task: Construct a minimal finite-state machine.
Question 7(a), GATE 2000: Alphabet {0,1}; accept exactly the strings containing neither 00 nor 11 as a substring.

Task: Construct a minimal finite-state machine.
Tap to enlarge
Shared context

Alphabet {0,1}; accept exactly the strings containing neither 00 nor 11 as a substring.

Answer & solution

Answer: Complete minimal DFA has four states: start, last-0, last-1, dead. (no official key was published)

1. Use states s (no symbol yet), z (valid prefix ending 0), o (valid prefix ending 1), and d (a forbidden equal adjacent pair has occurred). Start at s; accepting states are s,z,o, so ε is accepted.

2. Complete transition table, entries in input order 0,1: s→(z,o); z→(d,o); o→(z,d); d→(d,d). This is also a complete text specification of the requested machine.

3. Induction on the processed prefix proves the state invariant. Alternating bits move between z and o; a repeated bit enters d permanently. Thus precisely the required language is recognized.

4. All four states are reachable using ε,0,1,00. Dead d is distinguished from every accepting state by suffix ε. States s and z are distinguished by suffix 0, s and o by suffix 1, and z and o by suffix 0. Therefore no pair can merge and four states are minimal for a complete DFA. A partial drawing may omit the explicit dead state, but that is not a three-state complete DFA.

Original paper, page 7

1 mark · MCQ
Report issue

DFA for a fixed binary length

Finite Automata

Question 1.4, GATE 1999: For the regular expression consisting of n concatenated factors (0+1), find the minimum finite-automaton states; choice C is n+2 and B is n+1.
Tap to enlarge
Your answer
Answer & solution

Answer: C for a complete DFA (no official key was published)

The language contains exactly the binary strings of length n. Use states 0 through n to record how many symbols have been read and a dead state for lengths above n. State n alone accepts; both symbols advance the count, and the dead state loops. This constructs n+2 states. For i<j≤n, a suffix of length n−j accepts from j but not i, so all progress states are distinguishable. The dead state is distinguishable from each by an appropriate accepting suffix. A partial automaton or NFA could omit that state and use n+1, giving B. The source says finite automaton without explicitly saying complete deterministic; C uses that conventional interpretation, rather than a universal minimum across all automaton models.

Original paper, page 1

3 marks · Descriptive
Report issue

Decide strict inclusion of automaton languages

Finite Automata

Question 6(b), GATE 1999: Given finite automata M₁ and M₂, outline an algorithm to decide L(M₁)⊊L(M₂). The prose explicitly says strict subset even though a reproduced symbol permits equality.
Question 6(b), GATE 1999: Given finite automata M₁ and M₂, outline an algorithm to decide L(M₁)⊊L(M₂). The prose explicitly says strict subset even though a reproduced symbol permits equality.
Tap to enlarge
Shared context

Given finite automata M₁ and M₂, outline an algorithm to decide L(M₁)⊊L(M₂). The prose explicitly says strict subset even though a printed symbol permits equality.

Answer & solution

Answer: Require L(M₁)\L(M₂)=∅ and L(M₂)\L(M₁)≠∅. (no official key was published)

1. Put the automata over the same alphabet Σ, taking the union of their alphabets if needed. Determinize any NFAs and complete both resulting DFAs with sink states for missing transitions. This makes complementing acceptance correct.

2. Explore the product states (q₁,q₂) from the initial pair, with δ((q₁,q₂),a)=(δ₁(q₁,a),δ₂(q₂,a)). A reachable pair with q₁ accepting and q₂ rejecting witnesses a word in L(M₁)\L(M₂). If such a pair exists, answer NO.

3. Also look for a reachable pair with q₂ accepting and q₁ rejecting. If none exists, the languages are equal, so strict inclusion is false. If one exists while the first kind does not, answer YES.

4. Breadth-first or depth-first search suffices because a finite automaton language is nonempty exactly when an accepting state is reachable. On complete DFAs the search takes O(|Σ||Q₁||Q₂|) time; determinization can add exponential cost for NFA input. Both tests are necessary: ordinary inclusion alone incorrectly accepts equal languages.

Original paper, page 6

2 marks · MCQ
Report issue

Minimum DFA remembering equal final bits

Finite Automata

Question 2.5, GATE 1998: Over{0, 1}, accept exactly words whose last two symbols are equal. Find minimum states among 2, 5, 8, 3.
Tap to enlarge
Your answer
Answer & solution

Answer: B: 5 (no official key was published)

Step through it (2 parts)

Use five states: start S; nonaccepting q0 for a last 0 without an equal final pair; nonaccepting q1 analogously; accepting a 0 for suffix 00; accepting a 1 for suffix 11. On0, S→q0, q0/a 0→a 0, q1/a 1→q0. On1 use the symmetric transitions. To prove minimality, accepting versus nonaccepting states differ on ε. a 0 and a 1 differ on suffix 0; q0 and q1 differ on 0; S differs from q0 on 0 and from q1 on 1. All five are reachable, so no merging is possible. Therefore B.

Original paper, page 4

Descriptive
Report issue

Minimal DFA for multiples of five

Finite Automata

Question 4, GATE 1998: Design a minimum-state DFA for binary strings whose numeric value, ignoring leading zeros, is divisible by five.
Tap to enlarge
Answer & solution

Answer: Five remainder states if ε represents 0; six if an empty representation is excluded. (no official key was published)

Maintain the remainder r of the binary prefix modulo 5. Appending bit b changes a value v into 2v+b, so the transition is δ(qr,b)=q_((2r+b) mod 5). The start and sole accepting state is q0, using the conventional value 0 for ε.

State     input 0   input 1
q0        q0        q1
q1        q2        q3
q2        q4        q0
q3        q1        q2
q4        q3        q4

This transition table fully specifies the DFA. Leading zeros loop at q0, and zero is divisible by five. Induction on prefix length proves the invariant that state qr means the prefix value is congruent to r. Consequently the final state is accepting exactly for multiples of five.

For minimality, all five states are reachable: ε, 1, 10, 11 and 100 reach q0 through q4. Given distinct remainders r and s, choose v in {0,1,2,3,4} with 8r+v≡0 mod 5 and append its three-bit binary representation, including leading zeros. From qr the result is accepting. From qs its remainder differs by 8(s−r), which is nonzero modulo 5 because 8 is invertible modulo 5. Thus every pair is distinguishable, establishing a five-state lower bound.

The source says strings in {0,1}* but does not define the value of ε. If a binary numeral must contain at least one symbol, add a new nonaccepting start state s with 0→q0 and 1→q1. It is distinct from q0 by ε and from every other remainder state by the suffix argument, so this alternative language needs six states. The five-state answer uses the explicitly stated conventional interpretation.

Original paper, page 6

5 marks · Descriptive
Report issue

Minimum DFA for two divisibility conditions

Finite Automata

Question 20, GATE 1997: Construct a finite-state machine with the minimum number of states accepting exactly the strings over {a,b} whose number of a symbols is divisible by 2 and number of b symbols is divisible by 3.
Tap to enlarge
Answer & solution

Answer: Six-state DFA tracking (#a mod 2, #b mod 3); start and only accepting state q00. (no official key was published)

Step through it (2 parts)

The future acceptance of a prefix depends on two remainders, not on the order of its symbols. Let qij mean that the prefix contains i a's modulo 2 and j b's modulo 3. Use Q={q00,q01,q02,q10,q11,q12}; start at q00 and make only q00 accepting. An a toggles i, while a b advances j modulo 3.

State    on a    on b    Accepting?
q00      q10     q01     yes
q01      q11     q02     no
q02      q12     q00     no
q10      q00     q11     no
q11      q01     q12     no
q12      q02     q10     no

This table completely specifies the machine and can be drawn as two three-state b-cycles with paired a-transitions between them. By induction on input length, its state is always the pair of remainders claimed above. Therefore it accepts exactly the required strings, including the empty string because zero is divisible by both divisors.

To prove minimum size, first note that every qij is reachable by ai bj. Next take any distinct qij and qkl. Append the suffix a^((-i) mod 2)b^((-j) mod 3). From qij this reaches q00 and accepts. From qkl it reaches the nonzero remainder pair ((k−i) mod 2,(l−j) mod 3), so it rejects. Every pair of states is thus distinguishable by a common suffix. The six distinct residual languages require at least six DFA states; our six-state construction meets this lower bound. Merely multiplying 2 by 3 would suggest the answer but would not, without distinguishability, prove minimality.

Original paper, page 9

Descriptive
Report issue

Concatenate two finite automata

Finite Automata

Question 12(a), GATE 1996: M1 has states A(start,final),B(nonfinal), with A→B and B→A on either 0 or 1. M2 has C(start,final),D(final),E(nonfinal): C loops on a, C→D on b, D loops on b, D→E on a, and E loops on a,b. Construct an ε-NFA recognizing L1L2 using no new states and only added ε-transitions.
Question 12(a), GATE 1996: M1 has states A(start,final),B(nonfinal), with A→B and B→A on either 0 or 1. M2 has C(start,final),D(final),E(nonfinal): C loops on a, C→D on b, D loops on b, D→E on a, and E loops on a,b. Construct an ε-NFA recognizing L1L2 using no new states and only added ε-transitions.
Question 12(a), GATE 1996: M1 has states A(start,final),B(nonfinal), with A→B and B→A on either 0 or 1. M2 has C(start,final),D(final),E(nonfinal): C loops on a, C→D on b, D loops on b, D→E on a, and E loops on a,b. Construct an ε-NFA recognizing L1L2 using no new states and only added ε-transitions.
Question 12(a), GATE 1996: M1 has states A(start,final),B(nonfinal), with A→B and B→A on either 0 or 1. M2 has C(start,final),D(final),E(nonfinal): C loops on a, C→D on b, D loops on b, D→E on a, and E loops on a,b. Construct an ε-NFA recognizing L1L2 using no new states and only added ε-transitions.
Tap to enlarge
Answer & solution

Answer: Use start A, final states C,D; add A→C on ε, retaining every original transition. (no official key was published)

M1 accepts binary strings of even length: each 0 or 1 toggles A and B, and A is accepting. M2 accepts a*b*: it stays at C through a's, moves to D at the first b, and a later a leads to rejecting sink E. Both languages contain ε.

For concatenation, retain all original symbol-labelled edges and add A→C on ε, because A is the only accepting state of M1 and C is the initial state of M2. The combined machine has just one initial state, A. Its accepting states are C and D, the former accepting states of M2. A is no longer designated accepting, although ε is still accepted via the new ε-edge to C. B and E remain nonaccepting.

Any accepting run first follows a run of M1 ending at A, then uses the ε-edge and follows an accepting run in M2. The consumed string therefore factors as uv with u∈L1 and v∈L2. Conversely every such factorization gives an accepting run. This proves equivalence rather than just providing a diagram recipe.

Text diagram addition: A --ε--> C. Initial/final annotations must be updated as stated; “only add ε-transitions” refers to edges and state count, not to keeping two independent initial-state markings. No new states or symbol transitions are required.

Original paper, page 8

5 marks · Descriptive
Report issue

DFA excluding three consecutive b characters

Finite Automata

Question 27, GATE 1993: Draw a DFA over {a,b} accepting exactly strings with no substring bbb.
Tap to enlarge
Answer & solution

Answer: States q0,q1,q2 accepting, qD rejecting; start q0; a resets q0 before death; b advances q0→q1→q2→qD; qD loops. (no official key was published)

Step through it (2 parts)

While no forbidden substring has appeared, only the length of the trailing run of b characters matters. State q0 means zero trailing b's, q1 one, and q2 two. A third consecutive b makes the input permanently unacceptable, represented by rejecting sink qD.

Transition diagram as a complete edge list:
q0 --a--> q0; q0 --b--> q1
q1 --a--> q0; q1 --b--> q2
q2 --a--> q0; q2 --b--> qD
qD --a,b--> qD.
Start at q0; accepting states are q0,q1,q2. In particular epsilon is accepted, and bb is accepted but bbb is not.

Induct on the processed prefix: before a forbidden block occurs, the named state records its trailing b count; an a resets that count and a b increments it. Upon reaching three, qD is entered and can never be escaped, so later a's cannot erase an earlier violation. This invariant proves both acceptance of every valid string and rejection of every invalid one. Four states are also minimal: qD differs from all accepting states on epsilon, and q0,q1,q2 can be distinguished by appending b or bb as appropriate.

Original paper, page 15

5 marks · Descriptive
Report issue

Third-from-last bit: NFA and minimum DFA

Finite Automata

Question 17(b), GATE 1991: Let L be the set of binary strings whose third symbol from the right is 1. Construct an NFA for L and justify the number of states in its minimized equivalent DFA.
Tap to enlarge
Answer & solution

Answer: A four-state NFA suffices; the minimum DFA has exactly 8 states. (no official key was published)

The language is {0,1}*1{0,1}{0,1}. An NFA can guess which 1 will be third from last, then require exactly two more symbols before acceptance. Use states q0,q1,q2,q3; q0 is initial and q3 is the only accepting state. Missing transitions go to the empty set.

Transition table

State | on 0 | on 1
q0    | {q0} | {q0,q1}
q1    | {q2} | {q2}
q2    | {q3} | {q3}
q3    | {}   | {}

Equivalently, q0 has a loop labeled 0,1 and an additional edge labeled 1 to q1; q1→q2 and q2→q3 are labeled 0,1. A successful path stays at q0 through an arbitrary prefix, takes the guessing edge on a 1, and reads exactly two additional symbols. It ends in q3 precisely for the required strings.

For a DFA upper bound, store the most recent three bits, padding on the left with zeros before three bits have arrived. Use the eight states abc∈{0,1}^3, initial state 000, transition δ(abc,d)=bcd, and accepting states 100,101,110,111. After at least three inputs the first stored bit is exactly third from last; shorter strings remain nonaccepting because their padded first bit is zero. Every state is reachable by reading its three-bit label.

For minimality, take two different length-three strings x and y, differing at position r counted from the left, with 1≤r≤3. Append 0r−1 to both. In each resulting string, the third symbol from the right is precisely the old position r, so exactly one extension is accepted. Thus all eight three-bit strings have pairwise distinct right languages. By Myhill–Nerode, every DFA needs at least eight states. The construction meets this bound, proving that its minimized size is exactly 8.

Original paper, page 8