Skip to content
Official PYQ · 2000

GATE CS 2000 Q1.5 — Regular and Context-free Languages

Explain with AI

Let LL denote the languages generated by the grammar S→0S0∣00S \to 0S0 \mid 00.
Which of the following is TRUE?

Choose one option
View worked solution

Answer: B

To find the language LL generated by the given grammar, let us derive a few strings:

  • S→00S \to 00 (length 2)
  • S→0S0→0(00)0=0000S \to 0S0 \to 0(00)0 = 0000 (length 4)
  • S→0S0→0(0S0)0→00(00)00=000000S \to 0S0 \to 0(0S0)0 \to 00(00)00 = 000000 (length 6)

In general, each application of the rule S→0S0S \to 0S0 adds one 00 to the left and one 00 to the right, increasing the length of the string by 22. The derivation terminates with the rule S→00S \to 00, which contributes two 00s.

Thus, the language generated is the set of all even-length strings of 00s: L={02n∣n≥1}=(00)+L = \{ 0^{2n} \mid n \ge 1 \} = (00)^+

Let us evaluate the options:

  • Option A (L=0+L = 0^+): Incorrect. 0+0^+ contains strings of odd length (e.g., 0,0000, 000), which are not present in LL.
  • Option B (LL is regular but not 0+0^+): Correct. Since LL can be represented by the regular expression (00)+(00)^+, it is a regular language, and it is not equal to 0+0^+.
  • Option C (LL is context free but not regular): Incorrect. Every regular language is also context-free, but since LL is regular, the "not regular" part makes this statement false.
  • Option D (LL is not context free): Incorrect. Since LL is regular, it is also context-free.

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

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