GATE / CS ARCHIVE

GATE CSE 2010 / QUESTION 41

Minimum NFA for all substrings

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

GATE 2010, Q41 2 marks · MCQ
Report issue

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