Question
Consider the augmented grammar given below:
Let . The number of items in the set is: ________.
Official answer and solution
- Official answer
- 5
- From
- Official GATE 2019 answer key
Solution
Compute the LR(0) kernel items and perform closure to find the number of items in GOTO(I0, '<').
The augmented grammar is:
The initial state consists of:
To find , we take all items in where the dot precedes and advance the dot past :
Now compute :
- (initial kernel item)
- Since the dot is before non-terminal , add all -productions with the dot at the start:
- Since the dot in is before non-terminal , add all -productions with the dot at the start:
Listing all distinct items in :
There are exactly items in the set.
5
Omitting the closure for S after expanding L -> .S.
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2019 Computer Science and Information Technology (CS)
- Question
- 53 of 65, printed as CS Q.43
- 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.