Question
Given a Context-Free Grammar as follows:
Which ONE of the following statements is TRUE?
Official answer and solution
- Official answer
- C
- From
- Official GATE 2025 answer key
Solution
Check the LR(0) state reached on input d from the initial state for SLR(1) conflicts, and compare with LR(1)/LALR(1) lookaheads.
- Why is not SLR(1): In the initial state , shifting terminal
dleads to a state containing the LR(0) items and . Since puts , we have . On lookaheadc, SLR(1) has a shift-reduce conflict between shiftingc(in ) and reducing . - Why is LALR(1): In the LR(1) automaton, the state reached from on
dhas item (lookahead is onlya, notc, because at the start of is only followed bya), whereas the state reached afterbthendhas and (no conflict oncora). Moreover, these two states have different LR(0) cores and are never merged in LALR(1). Thus is LALR(1), not SLR(1).
Final answer
Option (C)
Common trap
Confusing this grammar with the standard example that is CLR(1) but not LALR(1) ().
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2025 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 40 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.