Question

Which one of the following languages over Σ={a,b}\Sigma = \{a, b\} is NOT context-free?

Choose one option
Official answer and solution
Official answer
C
From
Official GATE 2019 answer key

Solution

Analyze each language's pushdown automaton compatibility or use the pumping lemma for CFLs.

Let us examine the languages:

  • Option A: {wwR∣w∈{a,b}∗}\{ww^R \mid w \in \{a, b\}^*\} is the standard even palindrome language, which is generated by S→aSa∣bSb∣ϵS \to aSa \mid bSb \mid \epsilon and accepted by an NPDA. (Context-free)
  • Option B: {wanbnwR}\{w a^n b^n w^R\} is generated by S→aSa∣bSb∣AS \to aSa \mid bSb \mid A where A→aAb∣ϵA \to aAb \mid \epsilon. The PDA pushes ww, then matches anbna^n b^n, and finally matches wRw^R against the remaining stack. (Context-free)
  • Option C: {wanwRbn}\{w a^n w^R b^n\}. In any string of this language, the palindrome matching of ww with wRw^R is interleaved with the count matching of ana^n with bnb^n. A single stack cannot verify that wRw^R matches ww while simultaneously preserving the count nn of aa's to match against bnb^n appearing later. By the Pumping Lemma for CFLs, choosing s=apbpapbpaps = a^p b^p a^p b^p a^p shows that this language is NOT context-free.
  • Option D: {anbi∣i∈{n,3n,5n}}={anbn}∪{anb3n}∪{anb5n}\{a^n b^i \mid i \in \{n, 3n, 5n\}\} = \{a^n b^n\} \cup \{a^n b^{3n}\} \cup \{a^n b^{5n}\}. Each of these three languages is context-free, and context-free languages are closed under finite union. (Context-free)
Final answer

C

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2019 Computer Science and Information Technology (CS)
Question
41 of 65, printed as CS Q.31
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.