GATE / CS ARCHIVE

GATE CSE 2011 / QUESTION 42

Positive multiples of a fixed unary length

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

GATE 2011, Q42 2 marks · MCQ
Report issue

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