Definition of a language \(L\) with alphabet \(\{a\}\) is given as following.…
2011
Definition of a language \(L\) with alphabet \(\{a\}\) is given as following.
\(L = \left\{a^{nk} \mid k > 0, \:\: and \:\: n \text{ is a positive integer constant} \right\}\)
What is the minimum number of states needed in a DFA to recognize\(L\)?
- A.
\(k + 1\) - B.
\(n+ 1\) - C.
\(2^{n+1}\) - D.
\(2^{k+1}\)
Attempted by 207 students.
Show answer & explanation
Correct answer: B
Answer: n+1
Key idea: The language contains exactly the strings whose lengths are positive multiples of n. A DFA must track the remainder of the current length modulo n, and it must also distinguish the empty string (length 0) from positive multiples of n.
Construction (shows n+1 states suffice): build states {q0, q1, ..., q_{n-1}, q*} where q0 is the start state (not accepting), q_i (1 ≤ i ≤ n-1) represent remainder i, and q* is a special accepting state representing remainder 0 after reading at least n symbols (positive multiple of n).
Transitions: from q0 on 'a' go to q1; for 1 ≤ i ≤ n-2 go from q_i to q_{i+1}; from q_{n-1} go to q*; from q* on 'a' go to q1. These transitions cycle remainders correctly while keeping q0 non-accepting so the empty string is rejected and positive multiples of n are accepted.
This machine has exactly n+1 states and recognizes the language.
Minimality proof (shows no smaller DFA exists):
Consider the n+1 strings: ε, a, a^2, …, a^{n-1}, a^n. We show they are pairwise Myhill–Nerode distinguishable, so any DFA must have at least n+1 states.
For ε versus a^r with 1 ≤ r ≤ n-1, appending a^{n-r} gives: ε·a^{n-r}=a^{n-r} (not in the language), while a^r·a^{n-r}=a^n (in the language). So ε and a^r are distinguishable.
For a^i and a^j with 1 ≤ i < j ≤ n-1, appending a^{n-i} yields a^i·a^{n-i}=a^n (in the language) but a^j·a^{n-i}=a^{n+(j-i)} whose length is not a multiple of n (since 0 < j-i < n), so a^i and a^j are distinguishable.
For a^n versus any a^r with 1 ≤ r ≤ n-1, appending ε distinguishes them because a^n is in the language while a^r is not.
Thus all n+1 chosen strings are pairwise distinguishable, forcing any recognizing DFA to have at least n+1 states.
Combining the construction and the minimality proof, the minimal number of DFA states required is n+1.
A video solution is available for this question — log in and enroll to watch it.