Question
Consider the following augmented grammar with as the set of terminals.
Let . The number of items in the set is ______.
Official answer and solution
- Official answer
- 8
- From
- Official GATE 2021 answer key
Solution
Trace the LR(0) item set closures and GOTO transitions starting from state .
The augmented grammar has start symbol and non-terminal with productions:
State .
Taking the transition on terminal '<':
Among the items in , only has the dot immediately before '<'. Moving the dot gives the kernel item:
Since the dot is before non-terminal , the closure adds all productions of with the dot at the beginning:
Next, compute :
Among all items in , the only item with the dot before '<' is again .
Moving the dot past '<' gives the kernel item:
Taking the closure of adds the same 7 initial items for with the dot at the front:
- (kernel item)
Counting all distinct items in , we have items.
8
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2021 Computer Science and Information Technology - Session 2 (CS2)
- Question
- 61 of 65, printed as CS Q.51
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.