Consider the Grammar: T -> Qx Q -> RS R -> y | ε S -> z | ε Here x, y, z are…

2024

Consider the Grammar:
T -> Qx
Q -> RS
R -> y | ε
S -> z | ε
Here x, y, z are terminals and T, Q, R, S are non terminals.
What will be the follow set of the non terminal R?

  1. A.

    {x, y}

  2. B.

    {y, z}

  3. C.

    {z, x}

  4. D.

    {ε}

Attempted by 195 students.

Show answer & explanation

Correct answer: C

Key idea: compute which terminals can appear immediately after R in some sentential form.

  • R appears in the production Q -> R S, so first add First(S) \ {ε} to Follow(R). First(S) = {z}, so add z.

  • S can produce ε (S -> ε), so we must also add Follow(Q) to Follow(R).

  • Find Follow(Q): Q appears in T -> Q x, so x is in Follow(Q).

  • Combining these results gives Follow(R) = {z, x}. Note that ε is not included in a Follow set.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Mppsc Assistant Professor