Skip to content
Official PYQ · 2007

GATE CS 2007 Q31 — Regular and Context-free Languages

Explain with AI

Which of the following languages is regular?

Choose one option
View worked solution

Answer: C

To determine which language is regular, let us analyze each option:

  • Option A: L1={wwR∣w∈{0,1}+}L_1 = \{ww^R \mid w \in \{0, 1\}^+\} is the set of even-length palindromes. It requires a stack to match the symbols of ww with wRw^R in reverse order, making it context-free but not regular.
  • Option B: L2={wwRx∣x,w∈{0,1}+}L_2 = \{ww^Rx \mid x, w \in \{0, 1\}^+\} requires matching an arbitrary prefix wwRww^R followed by xx. Since the boundary between wwRww^R and xx is not fixed and wwRww^R requires memory, this language is not regular.
  • Option C: L3={wxwR∣x,w∈{0,1}+}L_3 = \{wxw^R \mid x, w \in \{0, 1\}^+\}. Let us simplify this expression:
    • Since w∈{0,1}+w \in \{0, 1\}^+, its first symbol must be some a∈{0,1}a \in \{0, 1\}. We can write w=ayw = a y for some y∈{0,1}∗y \in \{0, 1\}^*.
    • Then, wR=yRaw^R = y^R a.
    • Substituting these into the expression gives: wxwR=(ay)x(yRa)=a(yxyR)awxw^R = (ay) x (y^R a) = a (y x y^R) a
    • Since x∈{0,1}+x \in \{0, 1\}^+ (length ≥1\ge 1), the middle portion z=yxyRz = y x y^R is also a non-empty string in {0,1}+\{0, 1\}^+.
    • Thus, any string in L3L_3 simply starts and ends with the same symbol (00 or 11) and has a non-empty middle part (total length ≥3\ge 3).
    This can be represented by the regular expression: 0(0+1)+0+1(0+1)+10(0+1)^+0 + 1(0+1)^+1 Since we can write a regular expression for L3L_3, it is regular.
  • Option D: L4={xwwR∣x,w∈{0,1}+}L_4 = \{xww^R \mid x, w \in \{0, 1\}^+\} is not regular for the same reason as Option B, as it requires matching a suffix of the form wwRww^R.

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

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