Question
Consider the canonical parsing of the grammar below using terminals and non-terminals with as the start symbol.
Which one of the following options gives the number of shift-reduce conflicts that will occur in the ACTION table?
Official answer and solution
- Official answer
- D
- From
- Official GATE 2026 answer key
Solution
Construct the canonical LR(0) states containing reduce items (, , , , , , ) and count the shift-reduce conflicts in the LR(0) ACTION table.
In an parser, a state with a reduce item places a reduce action in every terminal column of the ACTION table (or we count each conflicting (state, terminal) entry or state-level shift-reduce conflict):
- Initial state : Closure of contains , , and the reduce item (from -production), with shift on ( contains identical closure items , , ).
- State : Contains , , and the reduce item , with shift on .
- State : Contains , , and the reduce item , with shift on .
- State : Contains , , , , which has reduce item and shift on .
These 5 states (, , , , and ) each contain both a shift item on a terminal ( respectively) and a completed reduce item ( in ; in ; in ), producing exactly 5 shift-reduce conflicts in the ACTION table.
Option (D)
Forgetting that , , or are distinct canonical states that also contain the -reduce / items.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2026 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 41 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.