Skip to content
GATEiit

GATE CSE 2024 Session 2 Q65: Number of items in GOTO(I0, S) for an SLR grammar

Question

Consider the following augmented grammar, which is to be parsed with a SLR parser. The set of terminals is {a,b,c,d,#,@}\{a, b, c, d, \#, @\}

S′→SS→SS∣Aa∣bAc∣Bc∣bBaA→d#B→@\begin{aligned} S' &\to S \\ S &\to SS \mid Aa \mid bAc \mid Bc \mid bBa \\ A &\to d\# \\ B &\to @ \end{aligned}

Let I0=CLOSURE({S′→∙S})I_0 = \text{CLOSURE}(\{S' \to \bullet S\}). The number of items in the set GOTO(I0,S)\text{GOTO}(I_0, S) is ___________

Try it: numerical answer: type the value

Numerical answer. No negative marking.
Show answer and explanation

Answer: 9 (official GATE 2024 final answer key)

Concept used: LR(0) items: GOTO advances the dot over SS, then the closure adds items for the non-terminal after the dot.

First step: GOTO gives S′→S∙S' \to S\bullet and S→S∙SS \to S\bullet S; the dot before SS pulls in all SS-productions and then the AA and BB productions.

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 2024 Session 2 CS question paper and final answer key, organised by IISc Bangalore. Question paper · Answer key