Question:

For a string \(w\), we define \(w^R\) to be the reverse of \(w\). Which of the following languages is/are context-free?

Show Hint

Context-free languages can enforce one reversal using a stack, but not two interleaved reversals.
Updated On: Dec 29, 2025
  • \( \{\, w x w^R x^R \mid w,x \in \{0,1\}^* \,\} \)
  • \( \{\, w w^R x x^R \mid w,x \in \{0,1\}^* \,\} \)
  • \( \{\, w x w^R \mid w,x \in \{0,1\}^* \,\} \)
  • \( \{\, w x x^R w^R \mid w,x \in \{0,1\}^* \,\} \)
Hide Solution
collegedunia
Verified By Collegedunia

The Correct Option is B, C, D

Solution and Explanation

Step 1: Analyze option (C).
The language \( \{ w x w^R \} \) is context-free since a PDA can push symbols of \(w\), ignore \(x\), and then pop to match \(w^R\). Hence, (C) is context-free.

Step 2: Analyze option (D).
The language \( \{ w x x^R w^R \} \) is a concatenation of two palindromic patterns and can be recognized by a PDA using a stack in two phases. Hence, (D) is context-free.

Step 3: Analyze option (B).
The language \( \{ w w^R x x^R \} \) is a concatenation of two palindromes, each of which is context-free, and CFLs are closed under concatenation. Hence, (B) is context-free.

Step 4: Eliminate option (A).
The language \( \{ w x w^R x^R \} \) requires simultaneous matching of two independent strings in cross order, which is not possible with a single stack PDA. Hence, (A) is not context-free.

Was this answer helpful?
0
0

Questions Asked in GATE CS exam

View More Questions