Skip to content
GATEiit

GATE CSE 2024 Session 2 Q40: Fill the missing cells of an LL(1) parsing table

Question

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

S→AaAb∣BbBaA→cS∣ϵB→dS∣ϵ\begin{aligned} S &\to AaAb \mid BbBa \\ A &\to cS \mid \epsilon \\ B &\to dS \mid \epsilon \end{aligned}

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

aabbccdd$\text{\textdollar}
SSS→AaAbS \to AaAbS→BbBaS \to BbBa(1)(2)
AAA→ϵA \to \epsilon(3)A→cSA \to cS
BB(4)B→ϵB \to \epsilonB→dSB \to dS

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.

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 2024 final answer key)

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

First step: Compute FIRST(AaAbAaAb), FIRST(BbBaBbBa), FOLLOW(AA) and FOLLOW(BB), then place each production in its cells.

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 2024 Session 2 CS question paper and final answer key, organised by IISc Bangalore. Question paper · Answer key