All Exams Test series for 1 year @ ₹349 only
Question

Consider the Grammar :

    S → A

    A → \(\$\)B\(\$\) | id

    B → B, A | A

If I0 = CLOSURE ({[S → .A]}) then, how many items be in the set for GOTO(I0, \(\$\))

This question was previously asked in
UGC NET 2024 Computer Science and Applications Question Paper (23-Aug-2024) (Shift 1)
The correct answer is

5

In LR(0) parsing, GOTO(I, X) is formed by moving the dot past the symbol X in every item of I that has X right after the dot, and then taking the CLOSURE of those kernel items. CLOSURE adds an item B → .γ for every production of a non-terminal B that appears immediately after a dot.

Step 1 — Build I0 = CLOSURE({[S → .A]}). The dot is before A, so both A-productions are added: S → .A, A → .\(\$\)B\(\$\), A → .id. Thus I0 has 3 items.

Step 2 — Kernel of GOTO(I0, \(\$\)): only A → .\(\$\)B\(\$\) has \(\$\) after the dot, giving the kernel item A → \(\$\).B\(\$\).

Step 3 — Closure: the dot is before B, so add B → .B, A and B → .A. The item B → .B, A again has B after the dot (already added). The item B → .A has A after the dot, so add A → .\(\$\)B\(\$\) and A → .id.

Step 4 — The final set is {A → \(\$\).B\(\$\), B → .B, A, B → .A, A → .\(\$\)B\(\$\), A → .id}, which contains 5 items.

Counting only 3 or 4 items misses the A-productions pulled in through B → .A, and 6 would double-count the recursive item B → .B, A, which appears only once in the set.

5 option is correct.

Was this answer helpful?

Important Questions from LR(0)

  1. Consider the canonical $LR(0)$ parsing of the grammar below using terminals $\{a, b, c\}$ and non-terminals $\{A, B, C, S\}$ with $S$ as the start symbol.

    $S \rightarrow ACB$
    $A \rightarrow aA \mid \epsilon$
    $C \rightarrow cC \mid \epsilon$
    $B \rightarrow bB \mid b$

    Which one of the following options gives the number of shift-reduce conflicts that will occur in the $LR(0)$ ACTION table?
Need Expert Advice?
Upcoming Exams
CTET
December 12, 2026
CBSE UGC NET
December 14, 2026
CSIR UGC NET
December 19, 2026
Test Series
UGC NET img
Teaching
UGC NET (Paper 2) 2026 Mock Test Series
796 Tests 2 Tests Free
219 Attempts
4.4(46)
English
More Questions from UGC NET

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App