Question
Let and let .
Which of the following constraints ensure(s) that the language is context-free?
Official answer and solution
- Official answer
- A, C and D
- From
- Official GATE 2026 answer key
Solution
Test whether a single LIFO stack (PDA) can verify each constraint when reading left to right.
Reading in order:
- (A) : A PDA can push 's, pop against 's (maintaining with a sign symbol), then push/pop 's and match against 's. Thus is context-free.
- (B) and : This imposes crossing dependencies ( with , and with ). By the pumping lemma for CFLs, is not context-free.
- (C) and : These are nested dependencies (, ). A PDA pushes 's, then pushes 's, pops the 's on reading , and finally pops the 's on reading . Thus is context-free.
- (D) : A PDA simply pushes one symbol for each and each ( symbols total), and pops one symbol for each and each ( symbols total). Thus is context-free.
Final answer
Options (A), (C), (D)
Common trap
Assuming is not context-free without noticing it is a single linear equation over counts that a counter PDA can track.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 48 of 65
- 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.