GateAI
Parsing

GATE CSE 2012 · Q53

MCQ2 marksMedium

Time

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. ε\varepsilon is the empty string, $\$ indicates end of input, and ∣\mid separates alternate right hand sides of productions. S→aAbB∣bAaB∣εS \rightarrow aAbB \mid bAaB \mid \varepsilon A→SA \rightarrow S B→SB \rightarrow S The appropriate entries for E1, E2, and E3 are

GATE CSE 2012 Q53 diagram

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: C) E1: S → aAbB, S → E2: S → bAaB, S → E3: B → S

Parsing

To find the entries of the LL(1) parsing table M[A,a]M[A, a]:

  1. For non-terminal SS:

    • Production S→aAbBS \rightarrow aAbB: FIRST(aAbB)={a}\text{FIRST}(aAbB) = \{a\}, so add S→aAbBS \rightarrow aAbB to M[S,a]M[S, a].

    • Production S→bAaBS \rightarrow bAaB: FIRST(bAaB)={b}\text{FIRST}(bAaB) = \{b\}, so add S→bAaBS \rightarrow bAaB to M[S,b]M[S, b].

    • Production S→εS \rightarrow \varepsilon: since ε∈FIRST(ε)\varepsilon \in \text{FIRST}(\varepsilon), add S→εS \rightarrow \varepsilon to M[S,t]M[S, t] for all t \in \text{FOLLOW}(S) = \{a, b, \\},i.e.,, i.e., M[S, a],, M[S, b],and, and M[S, \$]$.

    Therefore:

    • E1=M[S,a]={S→aAbB, S→ε}= M[S, a] = \{S \rightarrow aAbB,\ S \rightarrow \varepsilon\}

    • E2=M[S,b]={S→bAaB, S→ε}= M[S, b] = \{S \rightarrow bAaB,\ S \rightarrow \varepsilon\}

  2. For non-terminal BB:

    • Production B→SB \rightarrow S: FIRST(S)={a,b,ε}\text{FIRST}(S) = \{a, b, \varepsilon\}.

    • Add B→SB \rightarrow S to M[B,a]M[B, a] and M[B,b]M[B, b].

    • Since S⇒∗εS \Rightarrow^* \varepsilon, add B→SB \rightarrow S to M[B,t]M[B, t] for all t \in \text{FOLLOW}(B) = \{a, b, \\},whichincludes, which includes M[B, \$]$.

    Therefore:

    • E3 = M[B, \] = \{B \rightarrow S\}$

This matches option (C).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Parsing previous year question is Q53 of the GATE CSE 2012 paper. Find more GATE CSE PYQs on Parsing in Compiler Design, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Parsing PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Parsing in GATE CSE

Parsing has 23 GATE CSE PYQs across 16 papers from 2012 to 2026. 11 of them are 2-mark MCQs like this one, and GATE CSE 2012 has 2.

How GATE tests Parsing

More from GATE CSE 2012

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2012 · Q53 · MCQ

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. S → aAbB bAaB A → S B → S The appropriate entries for E1, E2, and E3 are

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.