StreakPeaked· Practice

ExamsGATETechnical

Consider the following context-free grammar where the start symbol is S and the set of terminals is {a,b,c,d}. S → AaAb | BbBa A → cS | ε B → dS | ε The following is a partially-filled LL(1) parsing table. Columns: a, b, c, d, Rows: S: (a) S → AaAb, (b) S → BbBa, (c) (1), (d) (2), () blank A: (a) A → ε, (b) (3), (c) A → cS, (d) blank, () blank B: (a) (4), (b) B → ε, (c) blank, (d) B → dS, () blank 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.

  1. (1) S → AaAb (2) S → BbBa (3) A → ε (4) B → ε
  2. (1) S → BbBa (2) S → AaAb (3) A → ε (4) B → ε
  3. (1) S → AaAb (2) S → BbBa (3) blank (4) blank
  4. (1) S → BbBa (2) S → AaAb (3) blank (4) blank

Correct answer: (1) S → AaAb (2) S → BbBa (3) A → ε (4) B → ε

Solution

The correct option is right because it accurately fills the LL(1) parsing table based on the productions of the grammar. For the non-terminal S, the first production is chosen for 'a' and the second for 'b', while A can derive ε for 'a' and B can also derive ε for 'b', aligning with the grammar's rules.

Related GATE Technical questions

⚔️ Practice GATE Technical free + battle 1v1 →