Skip to content
GATEiit

GATE CSE 2021 Set 1 Q41: Fill the blank cells of an LL(1) parsing table

Question

Consider the following context-free grammar where the set of terminals is {a,b,c,d,f}\{a, b, c, d, f\}.

S→d a T∣R fT→a S∣b a T∣ϵR→c a T R∣ϵ\begin{aligned} S &\to d\,a\,T \mid R\,f \\ T &\to a\,S \mid b\,a\,T \mid \epsilon \\ R &\to c\,a\,T\,R \mid \epsilon \end{aligned}

The following is a partially-filled LL(1) parsing table.

Which one of the following choices represents the correct combination for the numbered cells in the parsing table ("blank" denotes that the corresponding cell is empty)?

aabbccddff\$
S(1)S→d a TS \to d\,a\,T(2)
TT→a ST \to a\,ST→b a TT \to b\,a\,T(3)T→ϵT \to \epsilon(4)
RR→c a T RR \to c\,a\,T\,RR→ϵR \to \epsilon

Try it: multiple choice: exactly one correct option

Select one option
Wrong answer costs 2/3 mark in GATE.
Show answer and explanation

Answer: A (official GATE 2021 final answer key)

Concept used: LL(1) table: put A→αA \to \alpha under FIRST(α\alpha), and under FOLLOW(AA) when α\alpha can derive ϵ\epsilon.

First step: FIRST(R fR\,f) ={c,f}= \{c, f\}. For T→ϵT \to \epsilon, compute FOLLOW(TT) from R→c a T RR \to c\,a\,T\,R and S→d a TS \to d\,a\,T.

Full step-by-step solution

Detailed working, common mistakes and linked mock tests will be available with a free GATEiit account. Log-in is coming soon.

Share this question

WhatsAppDownload image

Source: official GATE 2021 Set 1 CS question paper and final answer key, organised by IIT Bombay. Question paper · Answer key