Home › GATE CS › PYQs › Theory of Computation › Context-Free Grammars & Push-Down Automata

Context-Free Grammars & Push-Down Automata — GATE CS Previous Year Questions

Practise GATE CS previous year questions on Context-Free Grammars & Push-Down Automata in Theory of Computation (TOC). Filter by year, marks and question type.

Public question previews

  • Consider the following grammar where S is the start symbol, and a and b are terminal symbols. S → aSbS | bS | ϵ. Which of the following statements is/are true? (2026 · 1 mark · MSQ)
  • Consider the following context-free grammar G. S → abaABAbba, A → aaBBAb | bBaba, B → aBb | ab. In the above grammar, S is the start symbol, a and b are terminal symbols, and A and B are non-terminal symbols. Let L(G) be the language generated by the grammar G. For a string s ∈ L(G), let n1(s) be the number of a’s in s and n2(s) be the number of b’s in s. Which of the following statements is/are true? (2026 · 2 marks · MSQ)
  • Which of the following grammars is/are ambiguous? (2026 · 1 mark · MSQ)
  • Consider the following context-free grammar G, where S, A, and B are the variables (non-terminals), a and b are the terminal symbols, S is the start variable, and the rules of G are described as: S -> aaB | Abb A -> a | aA B -> b | bB Which ONE of the languages L(G) is accepted by G? (2025 · 1 mark · MCQ)
  • Which ONE of the following languages is accepted by a deterministic pushdown automaton? (2025 · 1 mark · MCQ)