Skip to content
Official PYQ · 2011

GATE CS 2011 Q42 — Regular Expressions and Finite Automata

Explain with AI

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 = \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 LL?

Choose one option
View worked solution

Answer: B

The given language is defined over the alphabet {a}\{a\} as:

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

Since nn is a constant and kk is a positive integer (k=1,2,3,…k = 1, 2, 3, \dots), the language LL consists of strings of aa's whose lengths are positive multiples of nn:

L={an,a2n,a3n,… }L = \{a^n, a^{2n}, a^{3n}, \dots\}

Note that the empty string ϵ\epsilon (length 00) is not in LL because k>0k > 0.

DFA Construction

To recognize this language, we need to track the length of the input string modulo nn, while distinguishing the initial state (length 00) from a state where a positive multiple of nn has been read.

We can define the states of the minimal DFA as follows:

  • q0q_0: Start state (represents length 00). Non-accepting.
  • q1q_1: Represents length ≡1(modn)\equiv 1 \pmod n. Non-accepting.
  • q2q_2: Represents length ≡2(modn)\equiv 2 \pmod n. Non-accepting.
  • …\dots
  • qn−1q_{n-1}: Represents length ≡n−1(modn)\equiv n-1 \pmod n. Non-accepting.
  • qnq_n: Represents length ≡0(modn)\equiv 0 \pmod n and length >0> 0. Accepting.

The transitions are defined as:

  • q0→aq1q_0 \xrightarrow{a} q_1
  • qi→aqi+1q_i \xrightarrow{a} q_{i+1} for 1≤i<n1 \le i < n
  • qn→aq1q_n \xrightarrow{a} q_1

Minimality Verification

All these n+1n+1 states are pairwise distinguishable:

  • qnq_n is the only accepting state, so it is distinguishable from all other states.
  • For any two states qiq_i and qjq_j (where 0≤i<j≤n−10 \le i < j \le n-1), the shortest string of aa's required to reach the accepting state qnq_n is an−ia^{n-i} and an−ja^{n-j} respectively. Since i≠ji \ne j, these string lengths are different, making qiq_i and qjq_j distinguishable.

Thus, the minimum number of states required in the DFA is n+1n + 1.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Regular Expressions and Finite Automata questions