Skip to content
GATEiit

GATE CSE 2022 Q29: Number of LR(0) items in goto on +

Question

Consider the augmented grammar with {+,∗,(,),id}\{+, *, (, ), id\} as the set of terminals.

S′→SS→S+R∣RR→R∗P∣PP→(S)∣id\begin{aligned} S' &\to S \\ S &\to S + R \mid R \\ R &\to R * P \mid P \\ P &\to (S) \mid id \end{aligned}

If I0I_0 is the set of two LR(0)LR(0) items {[S′→S.],[S→S.+R]}\{[S' \to S.], [S \to S. + R]\}, then goto(closure(I0),+)goto(closure(I_0), +) contains exactly __________ items.

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 5 (official GATE 2022 final answer key)

Concept used: goto moves the dot over the symbol, then takes the closure of the resulting items.

First step: Only [S→S.+R][S \to S. + R] moves on ++, giving [S→S+.R][S \to S + .R]; now add the closure items for RR and PP.

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

WhatsAppDownload image

Source: official GATE 2022 CS question paper and final answer key, organised by IIT Kharagpur. Question paper · Answer key