GATE / CS ARCHIVE

GATE CSE 2022 / QUESTION 47

GATE CSE 2022 Q47

Theory of Computation · Regular Expressions & Languages · Full GATE CSE 2022 paper

GATE 2022, Q47 2 marks · MSQ
Report issue

Regular Expressions & Languages

Question 47, GATE 2022: Over Σ={a,b}, L1={a^n w a^n : w∈Σ*}, L2={w x w^R : w,x∈Σ*, |w|,|x|>0}. Select true statements: A both regular; B both context-free; C L1 regular and L2 context-free; D both context-free but neither regular. The source does not explicitly state the allowed n in L1.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A,B,C

In L1 the arbitrary middle word absorbs all content: if n=0 is allowed, L1=Σ*; if n is required positive, taking n=1 gives aΣ*a. Either reading is regular. L2 consists exactly of strings of length at least 3 whose first and last symbols agree: take w to be the first symbol and x the nonempty middle. Hence L2=aΣ+a ∪ bΣ+b is regular. Both are therefore context-free as well, so A, B, C are true and D is false.

For L2, any allowed decomposition has equal first and last symbols and at least one middle symbol. Conversely if those conditions hold, choose |w|=1 and put everything else in x. Longer equal/reversed boundary strings are optional witnesses, not extra restrictions. This existential choice is why the language is much simpler than a general palindrome language.

Original paper, page 31 · Answer key