GATE / CS ARCHIVE

GATE CSE 1991 / QUESTION 17(b)

Third-from-last bit: NFA and minimum DFA

Theory of Computation · Finite Automata · Full GATE CSE 1991 paper

GATE 1991, Q17(b) 5 marks · Descriptive
Report issue

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