For a string w, we define wR to be the reverse of w. For example, if w = 01101 then wR = 10110. Which of the following languages is/are context-free?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2021 Set 2 · Q41
Time
Select all that applyOne or more correct
Solution
Official answer: B) {wwR xxR w, x ∈ {0, 1}*}; C) {wxwR w, x ∈ {0, 1}*}; D) {wxxR wR w, x ∈ {0, 1}*}
Regular and Context-Free LanguagesLet us analyze each language:
Option A: This language requires matching two independent reversed patterns that are interleaved (cross-serial dependency). A single pushdown automaton cannot verify both against and against simultaneously. Hence, this language is not context-free.
Option B: This language is the concatenation of two CFLs: and , where both are standard context-free languages (even-length palindromes). Since CFLs are closed under concatenation, is context-free.
Option C: By choosing , any string can be written as . Thus, the language generates all strings over , i.e., , which is a regular language. Every regular language is also context-free.
Option D: Let . Then . Thus, any string of this form is for . Choosing gives all even-length palindromes . Therefore, the language is exactly the set of even-length palindromes, which is context-free.
Thus, the correct options are B, C, and D.
Try the question first, then check your work.
Examiner trap
Consider whether the patterns can be reduced using substitutions (e.g., or setting ), or expressed as a concatenation of simpler context-free languages.
This Regular and Context-Free Languages previous year question is Q41 of the GATE CSE 2021 Set 2 paper. Find more GATE CSE PYQs on Regular and Context-Free Languages in Theory of Computation, or browse all GATE CSE PYQs.
Free diagnostic
Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Regular and Context-Free Languages PYQs now with no account.
An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.
Regular and Context-Free Languages has 21 GATE CSE PYQs across 13 papers from 2011 to 2026. 4 of them are 2-mark MSQs like this one, and GATE CSE 2021 Set 2 has 2.
How GATE tests Regular and Context-Free LanguagesIndependent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.