GATE CS 2025 Set 1 | Question 45
Theory of Computation › Context Free Grammar · MCQ · 2 marks · Answer: C
- Question 45Theory of Computationmcq2 marksConsider the following two languages over , where are natural numbers:Which ONE of the following statements is CORRECT?
- A.Both and are context-free languages.
- B.is a context-free language but is not a context-free language.
- C.is not a context-free language but is a context-free language.✓
- D.Neither nor are context-free languages.
Answer: C
Solution
Answer: (C) is not context-free but is context-free. is context-free. We need . A PDA (or grammar) pushes one symbol for each and each , then pops one for each :
This generates . is not context-free. It requires and , i.e. two independent comparisons tied to . A single stack can match 's with 's, but after that the count is lost and cannot be compared again with the 's. By the pumping lemma for CFLs (pump ), fails to be context-free.S -> a S c | B B -> b B c | b c - A.
More GATE PYQ on Context Free Grammar
All GATE CS Theory of Computation PYQ →Attempt GATE CS 2025 Set 1 in real GATE exam mode
Full paper with a timer, the GATE interface and a topic-wise analysis — free.
Create free account →