Linked answer questions
Statement for Linked Answer Questions 52 and 53:
For the grammar below, a partial LL(1) parsing table is also presented along with the grammar. Entries that need to be filled are indicated as E1, E2, and E3. is the empty string, indicates end of input, and separates alternate right hand sides of productions.
| Non-terminal | |||
|---|---|---|---|
| E1 | E2 | ||
| error | |||
| E3 |
Shared with question 53.
Question
The FIRST and FOLLOW sets for the non-terminals A and B are
Official answer and solution
- Official answer
- A
- From
- Official GATE 2012 answer key
Solution
Compute FIRST and FOLLOW sets for non-terminals A and B in the given grammar.
- Grammar productions:
- Computing FIRST sets:
- .
- Since , .
- Since , .
- Computing FOLLOW sets:
- is start symbol, so .
- In : is followed by , so . is followed by nothing, so .
- In : is followed by , so . is followed by nothing, so .
- Thus, .
- Since , , meaning . Combined with , .
- Because , .
- Therefore:
- This matches option (A).
A
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2012 Computer Science and Information Technology (CS)
- Question
- 52 of 65, printed as CS Q.52
- 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.