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 ?
{z, x}
FOLLOW(A) is the set of terminals that can appear immediately to the right of A in some sentential form. For a production X → αAβ, FOLLOW(A) contains FIRST(β) − {ε}; if β can derive ε, FOLLOW(A) also contains FOLLOW(X). ε never belongs to a FOLLOW set.
Step 1 — From T → Qx, the terminal x follows Q, so FOLLOW(Q) = {x}.
Step 2 — R appears only in Q → RS, where it is followed by S. FIRST(S) = {z, ε}, so z is added to FOLLOW(R).
Step 3 — Because S is nullable (S → ε), whatever follows Q also follows R, so FOLLOW(Q) = {x} is added.
Step 4 — FOLLOW(R) = {z, x}.
The set {x, y} wrongly includes y, which is FIRST(R) itself and never appears after R; {y, z} confuses FIRST(Q) with FOLLOW(R); {ε} is impossible because ε is never placed in a FOLLOW set.
{z, x} option is correct.