Question

Definition of a language LL with alphabet {a}\{a\} is given as following.

L={ank∣k>0, and n is a positive integer constant}L = \{a^{nk} \mid k > 0, \text{ and } n \text{ is a positive integer constant}\}

What is the minimum number of states needed in a DFA to recognize LL?

Choose one option
Official answer and solution
Official answer
B
From
Official GATE 2011 answer key

Solution

Construct the minimal DFA recognizing non-zero multiples of positive constant nn.

  1. The language is L={ank∣k>0}={an,a2n,a3n,… }L = \{a^{nk} \mid k > 0\} = \{a^n, a^{2n}, a^{3n}, \dots\}. Crucially, k>0k > 0 implies that the empty string ϵ\epsilon (k=0k = 0) is NOT accepted by LL.
  1. The DFA must count input symbols modulo nn while distinguishing the initial string length 0 from subsequent non-zero multiples of nn.
  1. Let states be q0,q1,q2,…,qn−1,qnq_0, q_1, q_2, \dots, q_{n-1}, q_n:
  • q0q_0: start state (non-accepting, representing string of length 0).
  • Reading aa transitions: q0→aq1→aq2⋯→aqn−1→aqnq_0 \xrightarrow{a} q_1 \xrightarrow{a} q_2 \dots \xrightarrow{a} q_{n-1} \xrightarrow{a} q_n.
  • qnq_n: accepting state, reached after reading nn symbols (k=1k = 1).
  • From qnq_n, reading aa transitions back to q1q_1 to count the next block of nn symbols.
  1. The states q0q_0 and qnq_n cannot be merged because q0q_0 is non-accepting while qnq_n is accepting. Hence, exactly n+1n + 1 states are necessary and sufficient.
Final answer

B

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2011 Computer Science and Information Technology (CS)
Question
42 of 65, printed as CS Q.42
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.