Skip to content
Official PYQ · 1996

GATE CS 1996 Q1.10 — Regular and Context-free Languages

Explain with AI

Let L⊆Σ∗L \subseteq \Sigma^* where Σ={a,b}\Sigma = \left\{a,b \right\}. Which of the following is true?

Choose one option
View worked solution

Answer: D

To determine which of the given languages is regular, we analyze each option based on the memory requirements of a Finite Automaton (FA):

  • Option A: L={x∣x has an equal number of a’s and b’s}L = \{x \mid x \text{ has an equal number of } a\text{'s and } b\text{'s}\}
    This language requires comparing the total count of aa's with the total count of bb's. Since the length of the string is unbounded, a finite automaton would need infinite states to keep track of the difference between the counts. Thus, it is not regular (it is context-free).
  • Option B: L={anbn∣n≥1}L = \{a^n b^n \mid n \geq 1\}
    This language requires matching the exact number of leading aa's with the subsequent bb's. Since nn can be arbitrarily large, it requires infinite memory (a stack) to count. Thus, it is not regular (it is context-free).
  • Option C: L={x∣x has more a’s than b’s}L = \{x \mid x \text{ has more } a\text{'s than } b\text{'s}\}
    Similar to Option A, this requires comparing the counts of aa's and bb's, which cannot be done with a finite number of states. Thus, it is not regular (it is context-free).
  • Option D: L={ambn∣m≥1,n≥1}L = \{a^m b^n \mid m \geq 1, n \geq 1\}
    Here, the powers mm and nn are independent. The language simply consists of strings containing one or more aa's followed by one or more bb's. This can be defined by the regular expression a+b+a^+b^+ (or aa∗bb∗a a^* b b^*). Since we can easily construct a Deterministic Finite Automaton (DFA) for this language, it is regular.

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

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