Question
Consider the following context-free grammar where the start symbol is and the set of terminals is .
The following is a partially-filled LL(1) parsing table.
| (1) | (2) | ||||
| (3) | |||||
| (4) |
Which one of the following options represents the CORRECT combination for the numbered cells in the parsing table?
Note: In the options, "blank" denotes that the corresponding cell is empty.
Official answer and solution
- Official answer
- A
- From
- Official GATE 2024 answer key
Solution
Compute , , , and .
- FIRST sets for productions of :
- Since , we have . Therefore, cell (1) (row , column ) contains .
- Since , we have . Therefore, cell (2) (row , column ) contains .
- FOLLOW sets for -productions of and :
- In , the first is followed by terminal and the second is followed by terminal , so . Since , cell (3) (row , column ) contains .
- In , the first is followed by terminal and the second is followed by terminal , so . Since , cell (4) (row , column ) contains .
Final answer
Option (A)
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2024 Computer Science and Information Technology - Set 2 (CS2)
- Question
- 40 of 65
- 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.