Skip to content
Official PYQ · 2014

GATE CS 2014 Set 1 Q15 — Regular and Context-free Languages

Explain with AI

Which one of the following is TRUE?

Choose one option
View worked solution

Answer: C

To determine which language is regular, we analyze each option:

  • Option A: L={anbn∣n≥0}L = \{a^n b^n \mid n \geq 0\} is a classic non-regular language. It requires infinite memory (a stack) to ensure the number of aa's matches the number of bb's.
  • Option B: L={an∣n is prime}L = \{a^n \mid n \text{ is prime}\} is not regular. The gap between consecutive prime numbers grows arbitrarily large, which violates the pumping lemma for regular languages.
  • Option C: L={w∣w has 3k+1 b’s for some k∈N}L = \{w \mid w \text{ has } 3k+1 \text{ } b\text{'s for some } k \in \mathbb{N}\} is regular. We only need to count the number of bb's modulo 3. This can be recognized by a Deterministic Finite Automaton (DFA) with 3 states, where the transitions on symbol aa remain in the same state, and transitions on bb cycle through the states.
  • Option D: L={ww∣w∈{0,1}∗}L = \{ww \mid w \in \{0,1\}^*\} is not regular. It requires remembering the entire first half of the string ww to match it with the second half, which cannot be done with finite states.

Thus, only Option C is regular.

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

Published
Report a correction
Keep exploringMore Regular and Context-free Languages questions