GATE CSE Context-Free Grammars and PDAs PYQs
Context-Free Grammars (CFG) and Pushdown Automata (PDA) form a cornerstone of the GATE CS Theory of Computation syllabus. Questions systematically test the boun… Read the guide
- Questions
- 26
- Asked
- since 2011
- Total marks
- 41
- Marks / paper
- 1.6
26 GATE CSE Context-Free Grammars and PDAs PYQs with solutions, from Theory of Computation. Browse all GATE CSE PYQs.
Questions
Every official paper that asked this topic, newest first.
- GATE CSE 2026 Set 1 · Q25Consider the following grammar where is the start symbol, and and are terminal symbols. Which of the following statements is/are true?MSQ1 markMediumSolve
- GATE CSE 2026 Set 1 · Q52Consider the following context-free grammar . In the above grammar, is the start symbol, and are terminal symbols, and and are non-terminal symbols. Let be the language generated by the grammar .…MSQ2 marksMediumSolve
- GATE CSE 2026 Set 2 · Q29Which of the following grammars is/are ambiguous?MSQ1 markEasySolve
- GATE CSE 2026 Set 2 · Q48Let and let . Which of the following constraints ensure(s) that the language is context-free?MSQ2 marksMediumSolve
- GATE CSE 2025 Set 1 · Q19Consider the following context-free grammar , where , , and are the variables (non-terminals), and are the terminal symbols, is the start variable, and the rules of are described as: …MCQ1 markEasySolve
- GATE CSE 2025 Set 2 · Q24Which ONE of the following languages is accepted by a deterministic pushdown automaton?MCQ1 markEasySolve
- GATE CSE 2024 Set 1 · Q59Let be a context-free grammar in Chomsky Normal Form with and containing 10 variable symbols including the start symbol . The string is derivable from . The number of steps (application of rules) in the derivation …NAT2 marksEasySolve
- GATE CSE 2024 Set 2 · Q52Consider a context-free grammar with the following 3 rules. Let . Let , , denote the number of times occur in , respectively. Which of the following statements is/are TRUE?MSQ2 marksMediumSolve
- GATE CSE 2023 · Q39Consider the context-free grammar below where and are non-terminals, and and are terminal symbols. The starting non-terminal is . Which one of the following statements is CORRECT?MCQ2 marksMediumSolve
- GATE CSE 2023 · Q40Consider the pushdown automaton (PDA) below, which runs on the input alphabet , has stack alphabet , and has three states , with being the start state. A transition from state to state , labelled , where is an input symbol or …MCQ2 marksMediumDiagramSolve
- GATE CSE 2022 · Q48Consider the following languages: Which of the following statements is/are FALSE?MSQ2 marksMediumSolve
- GATE CSE 2021 Set 1 · Q1Suppose that is a regular language and is a context-free language. Which one of the following languages is NOT necessarily context-free?MCQ1 markMediumSolve
- GATE CSE 2021 Set 1 · Q51In a pushdown automaton , a transition of the form, where , , and , represents Consider the following pushdown automaton over the input alphabet …NAT2 marksMediumDiagramSolve
- GATE CSE 2020 · Q10Consider the language and the following statements. I. is deterministic context-free. II. is context-free but not deterministic context-free. III. is not LL() for any . Which of the above statements is/are TRUE?MCQ1 markMediumSolve
- GATE CSE 2017 Set 1 · Q10Consider the following context-free grammar over the alphabet with as the start symbol: Which one of the following represents the language generated by the above grammar?MCQ1 markMediumSolve
- GATE CSE 2017 Set 1 · Q34If is a grammar with productions where is the start variable, then which one of the following strings is not generated by ?MCQ2 marksEasySolve
- GATE CSE 2017 Set 1 · Q37Consider the context-free grammars over the alphabet given below. and are non-terminals. The language isMCQ2 marksMediumSolve
- GATE CSE 2017 Set 2 · Q16Identify the language generated by the following grammar, where is the start variable. MCQ1 markEasySolve
- GATE CSE 2016 Set 1 · Q16Which of the following languages is generated by the given grammar? MCQ1 markEasySolve
- GATE CSE 2016 Set 1 · Q42Consider the following context-free grammars: Which one of the following pairs of languages is generated by and , respectively?MCQ2 marksMediumSolve
- GATE CSE 2016 Set 1 · Q43Consider the transition diagram of a PDA given below with input alphabet and stack alphabet . is the initial stack symbol. Let denote the language accepted by the PDA. Which one of the following is TRUE?MCQ2 marksMediumDiagramSolve
- GATE CSE 2016 Set 2 · Q17Language is defined by the grammar: Language is defined by the grammar: Consider the following statements: : is regular : is regular Which one of the following is ?MCQ1 markEasySolve
- GATE CSE 2016 Set 2 · Q43Consider the following languages: Which one of the following is TRUE?MCQ2 marksEasySolve
- GATE CSE 2015 Set 1 · Q51Consider the NPDA , where (as per usual convention) is the set of states, is the input alphabet, is the stack alphabet, is the state transition function, is the initial…MCQ2 marksMediumDiagramSolve
- GATE CSE 2015 Set 3 · Q32Which of the following languages are context-free? MCQ2 marksMediumSolve
- GATE CSE 2011 · Q8Which of the following pairs have DIFFERENT expressive power?MCQ1 markEasySolve
What GATE tests in Context-Free Grammars and PDAs
Concepts, patterns, formulas and traps distilled from past papers.
Context-Free Grammars (CFG) and Pushdown Automata (PDA) form a cornerstone of the GATE CS Theory of Computation syllabus. Questions systematically test the boundary between Regular, DCFL, CFL, and non-CFL classes, structural invariants of grammars (ambiguity, terminal count ratios, derivation steps), and operational tracing of PDAs. Over recent years, the topic has expanded from standard single-choice language classifications to multi-select invariant verification and exact counting NAT questions.
Core concepts
- Deterministic Pushdown Automata (DPDA) vs Non-Deterministic Pushdown Automata (NPDA)
- Deterministic Context-Free Languages (DCFL) and strict inclusion: Regular ⊂ DCFL ⊂ CFL
- Single stack mechanics: nested comparisons (ai bj cj di) vs cross-serial non-CFL dependencies (ai bj ci dj)
- Closure properties of CFLs and DCFLs (closure under regular intersection, non-closure under general intersection and complement)
- Grammar ambiguity, leftmost/rightmost derivations, and parse trees
- Chomsky Normal Form (CNF) structural derivation step counting
- LL(k) lookahead limitations on DCFLs vs unambiguous CFGs
- PDA acceptance modes (final state vs empty stack) and -transitions
- Context-free grammar derivations and language generation
- Net non-terminal balance in complete derivations
- Counting arguments over terminal occurrences
- Boundary cases and minimal-length string counterexamples
- Pushdown Automata (PDA) transition diagrams and formal definitions
- Stack operations (push, pop, replace/noop)
- Acceptance by empty stack vs. acceptance by final state
- Epsilon transitions and stack-emptying loops
- Deriving language relations and inequalities (e.g., am bn where n < m, m ≥ 1)
Recurring question patterns
Language Identification from CFG
CommonMCQ1.5 marks2025, 2023, 2017, 2016Given a CFG with recursive and non-recursive productions, determine the exact regular expression or set-builder notation of the language generated.
CFL vs. DCFL vs. Non-CFL Language Classification
Commonmixed2 marks2026, 2022, 2020, 2016Given multiple parameterized languages (e.g., with linear constraints or variations), identify which are Context-Free, Deterministic Context-Free, or non-Context-Free based on single-stack LIFO nesting versus cross-serial dependencies.
PDA State Transition & Execution Tracing
Occasionalmixed2 marks2021, 2016, 2015Given a formal 6/7-tuple or transition diagram of an NPDA/DPDA, analyze stack operations (push/pop/noop) to find accepting suffixes or count the number of accepted strings of fixed length.
Grammar Ambiguity and Derivation Counting
OccasionalMSQ1 marks2026Determine if a grammar is ambiguous by finding multiple distinct parse trees/leftmost derivations for a short test string, or count unique rightmost derivations.
Grammar Invariants and Terminal Inequalities
OccasionalMSQ2 marks2026, 2017Analyze productions to establish mathematical invariants over the number of generated terminals (e.g., bounds on vs. ).
Closure Properties and Expressive Power Hierarchy
CommonMCQ1 marks2025, 2022, 2021, 2011Evaluate truth values of statements involving closure under intersection with regular sets, complementation, difference, or relative power of DPDA vs. NPDA vs. DFA/NFA.
Chomsky Normal Form (CNF) Derivations
RareNAT2 marks2024Compute the exact number of derivation steps required to generate a terminal string of given length using a grammar in CNF.
Terminal Count Invariants via Derivation Rule Balance
OccasionalMSQ2 marks2024Given a CFG, determine which equality or inequality relations over terminal counts (e.g., ) hold for all words by setting up linear equations over production rule application counts.
PDA Language Identification via State and Stack Tracing
CommonMCQ2 marks2023Given a formal transition diagram or definition of a PDA (with transition format ), trace state transitions, push/pop actions, and non-deterministic or -transitions to deduce the exact set of accepted strings under a specified acceptance criterion (e.g., acceptance by empty stack).
Formulas GATE uses
Derivation Steps in Chomsky Normal Form (CNF)
Used to find the exact number of derivation steps to generate any terminal string of length from a CFG in CNF ( binary rule applications and terminal rule applications).
CFL Set Difference Identity
Used when reasoning about why is not necessarily context-free, as CFLs are not closed under complementation.
PDA Stack Balance Invariant
Used to compute acceptance conditions on input lengths (e.g., with total length yielding valid range for ).
Non-terminal Conservation Law
Used to establish linear relations between production rule application counts , where is the net change in non-terminals produced by rule .
Terminal Count Accumulation
Used to express the total count of terminal symbol in word in terms of the number of times each production rule is applied.
PDA Transition Notation
Used to describe moving from state to upon reading input symbol with top stack symbol , replacing with string .
Language Acceptance by Empty Stack
Used when the PDA accepts a word precisely when the stack becomes completely empty after processing the input.
Examiner traps in Context-Free Grammars and PDAs
- Assuming CFLs are closed under complementation or intersection (forgetting L1 ∩ L2 can be non-CFL even if both are DCFLs).
- Confusing nested LIFO dependencies (context-free) with interleaved/cross-serial dependencies (non-context-free).
- Assuming DPDA and NPDA have equivalent expressive power (unlike DFA and NFA).
- Overlooking base conditions or -productions in CFGs, leading to off-by-one errors in terminal constraints (e.g., m > n vs m ≥ n, or n ≥ 0 vs n ≥ 1).
- Missing non-deterministic transitions in PDA diagrams where stack symbols are read without being altered (Z → Z).
- Forgetting that deriving is not counted by 2n-1 in CNF without special start symbol handling.
- Confusing non-strict inequalities (≥) with strict inequalities (>), which fail on the minimal base strings (e.g., w = c yielding na = 0, nb = 0, violating na > nb).
- Forgetting the initial start symbol count (+1) when balancing non-terminal net changes.
- Assuming linear relationships based only on a subset of derivation paths rather than universal derivation invariants.
- Overlooking initial requirements to read a symbol from the bottom stack marker (e.g., missing m ≥ 1).
- Confusing strict inequality (n < m) with non-strict inequality (n ≤ m) by failing to count stack symbols consumed during -transitions to the emptying state.
- Assuming acceptance requires a final state when acceptance by empty stack is explicitly specified.
How questions are asked
- Identify language expression generated by a CFG
- Classify languages as Regular, DCFL, CFL, or non-CFL under given index constraints
- Compute number of accepted strings of fixed length in a PDA (NAT)
- Calculate derivation steps in CNF for a given string length (NAT)
- Determine ambiguity and count distinct derivations for a test string (MSQ)
- Find terminal ratio and inequality invariants of a grammar (MSQ)
- Identify valid input suffix for PDA acceptance given prefix state
- Symbol count relation verification (MSQ)
- Algebraic derivation property testing
- Identify language accepted by a given PDA transition diagram
- Determine boundary constraints on symbol counts (m, n) accepted by a PDA
Paper trends
Shift from standard 1-mark classification MCQs to multi-select (MSQ) questions evaluating multiple language constraints simultaneously (e.g., nested vs cross-serial powers).
2026, 2022
Introduction of NAT questions involving exact combinatorial counting based on PDA stack dynamics or grammar normal form derivations.
2024, 2021
Increased focus on structural invariants of non-terminals (proving ratio bounds on terminal counts across recursive branches).
2026, 2017
Shift toward multi-select questions (MSQ) testing invariant terminal-count relations and boundary-case validation (e.g., base derivation strings disproving strict inequalities).
2024
Recent questions emphasize rigorous boundary condition checking (e.g., strictly vs , and vs ) via -transitions requiring stack symbol consumption for empty-stack acceptance.
2023
Difficulty notes
Easy: Direct language generation of linear/simple CFGs, standard closure definitions, or basic hierarchy questions (DPDA vs NPDA). Medium: Multi-variable linear constraints on index tuples (), PDA state-stack tracing with non-deterministic transitions, proving grammar invariants via induction on derivation rules, and MSQs requiring counterexamples for non-CFL/ambiguity claims.