Consider the following languages: L1 = {an w an w ∈ {a,b}*} L2 = {w x wR w, x ∈ {a,b}*, |w|, |x| > 0} Note that wR is the reversal of the string w. Which of the following is/are TRUE?
Topic-wise GATE CS PYQs with verified steps
GATE CSE 2022 · Q47
Time
Select all that applyOne or more correct
Solution
Official answer: A) L1 and L2 are regular.; B) L1 and L2 are context-free.; C) L1 is regular and L2 is context-free.
Regular and Context-Free LanguagesLet us analyze both languages:
Language :
For , . Since can be any string in , setting generates all strings in . Thus:
This is clearly a regular language (and consequently context-free).
Language :
Since , let the first symbol of be . Then ends with the same symbol . Because has length at least , the total length of any string in is at least .
Conversely, any string of length that starts and ends with the same symbol can be written with (where is simply the first character) and as the remaining inner substring of length . Thus:
This language is generated by a regular expression and is recognized by a finite automaton, so is regular (and consequently context-free).
Since every regular language is also context-free:
(A) and are regular: TRUE
(B) and are context-free: TRUE
(C) is regular and is context-free: TRUE
(D) and are context-free but not regular: FALSE (they are regular)
Try the question first, then check your work.
Examiner trap
Check the language generated when setting in and in . Remember that every regular language is also context-free.
This Regular and Context-Free Languages previous year question is Q47 of the GATE CSE 2022 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 it is the only one in GATE CSE 2022.
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.