GATE CSE 2025 Session 2 Q51: LL(1) and ambiguity of two if-then-else grammars
- Compiler Design
- 2 marks
- MSQ
- No negative marking
Question
Consider two grammars and with the production rules given below:
:
:
where are the terminals.
Which of the following option(s) is/are CORRECT?
Try it: multiple select: one or more correct options
Select all correct options. No negative marking, no partial marks.
Show answer and explanation
Answer: C, D (official GATE 2025 final answer key)
Concept used: Alternatives sharing a FIRST set break LL(1); the dangling-else construction makes a grammar ambiguous.
First step: In both grammars two alternatives can start with ; then look for two parse trees of in .
Full step-by-step solution
Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.
Share this question
Source: official GATE 2025 Session 2 CS question paper and final answer key, organised by IIT Roorkee. Question paper · Answer key
More Compiler Design PYQs
- 2026 Session 1 · Q27Classify errors in three C string declarations
- 2026 Session 1 · Q28True statements about LL(1) parsing
- 2026 Session 1 · Q42Redundant (common) subexpressions in blocks B4 and B5 of a CFG
- 2026 Session 1 · Q53Compare two SDDs for type declarations
- 2026 Session 2 · Q35Count tokens produced by a lexer for a given string
- 2026 Session 2 · Q41Shift-reduce conflicts in the LR(0) table of a grammar