Consider the Grammar: S → A A → $B$ | id B → B, A | A If I₀ = CLOSURE({[S →…
2024
Consider the Grammar:
S → A
A → $B$ | id
B → B, A | A
If I₀ = CLOSURE({[S → .A]}), then how many items will be in the set for GOTO(I₀, $)?
- A.
3
- B.
4
- C.
5
- D.
6
Attempted by 118 students.
Show answer & explanation
Correct answer: C
Clarification: the $ characters in the original statement are LaTeX/math delimiters. The grammar is:
S → A
A → B | id
B → B , A | A
Compute CLOSURE({S → . A}): include any production whose left-hand side matches a nonterminal immediately after a dot.
The items in the closure are:
S → . A
A → . B
A → . id
B → . B , A
B → . A
There are five distinct items in this closure, so the correct count is 5.
Note: the original question wrote GOTO(I₀, $) — the $ symbols in the statement appear to be formatting delimiters. The intended question/answer corresponds to the closure above, which contains five items.
A video solution is available for this question — log in and enroll to watch it.