StreakPeaked· Practice

ExamsGATEEngineering Mathematics

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 → a A b B | b A a B | ε A → S B → S The FIRST and FOLLOW sets for the non-terminals A and B are

  1. (A) FIRST(A) = {a, b, ε} = FIRST(B) FOLLOW(A) = {a, b} FOLLOW(B) = {a, b, }
  2. (B) FIRST(A) = {a, b, } FOLLOW(A) = {a, b} FOLLOW(B) =
  3. (C) FIRST(A) = {a, b, ε} = FIRST(B) FOLLOW(A) = {a, b} FOLLOW(B) = ∅
  4. (D) FIRST(A) = {a, b} = FIRST(B) FOLLOW(A) = {a, b} FOLLOW(B) = {a, b}

Correct answer: (A) FIRST(A) = {a, b, ε} = FIRST(B) FOLLOW(A) = {a, b} FOLLOW(B) = {a, b, }

Solution

The correct option is right because both A and B derive from S, which can produce ε, a and b, leading to the same FIRST set of {a, b, ε}. Additionally, the FOLLOW sets correctly reflect the symbols that can appear immediately after A and B in the derivations, including the end of input symbol for B.

Related GATE Engineering Mathematics questions

⚔️ Practice GATE Engineering Mathematics free + battle 1v1 →