IAE Academy

GATE 2026 CS2 Q.41: solution and answer

GATE 2026 · CS2Q.41 · 2 marks · MCQ

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?

  1. (A)

    2

  2. (B)

    3

  3. (C)

    4

  4. (D)

    5

See the question in the paper

Answer and solution

ANSWER

The ACTION table has 5 shift-reduce conflicts, option (D).

Official answer: DSource: Official answer key, GATE 2026 CS2 (IIT Guwahati)

  1. Augment the grammar with . In an automaton a complete item puts a reduce entry in every terminal column. A shift-reduce conflict therefore occurs in a state for each terminal that has an item in that state alongside a complete item.

  2. . The state shifts on and also reduces on . This is 1 conflict, on .

  3. . It shifts on and reduces on . This is 1 conflict, on . Also , and , which has no shift item.

  4. . It shifts on and reduces on . This is 1 conflict, on .

  5. . It has no complete item, so no conflict.

  6. . It shifts on and reduces on . This is 1 conflict, on . Also , and , which has no shift item.

  7. From , . It shifts on and reduces on . This is 1 conflict, on . Also .

  8. The remaining states are , and . Each has a complete item and no shift item, so none has a conflict.

  9. Total: shift-reduce conflicts, which is option (D).

KEY IDEA

In , a complete item reduces on every terminal. So a state with a complete item and an item conflicts on . Here the -productions and and the production (beside ) each create such a state.

WATCH OUT FOR

Counting only states, or only the first state of each loop, and missing that the looping states and conflict again. Another slip is to count a state that has several reduce entries as one conflict per entry rather than one per terminal.

From the GATE 2026 CS2 paper. Every question of this paper · Download the full paper · All 13 Parsing questions, with notes

More Parsing questions