All Exams Test series for 1 year @ ₹349 only
Question

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 ?

This question was previously asked in
UGC NET 2024 Computer Science and Applications Question Paper (23-Aug-2024) (Shift 1)
The correct answer is

{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.

Was this answer helpful?

Important Questions from First and Follow

  1. Which of the following statement(s) is/are TRUE while computing First and Follow during top down parsing by a compiler?
Need Expert Advice?
Upcoming Exams
CTET
December 12, 2026
CBSE UGC NET
December 14, 2026
CSIR UGC NET
December 19, 2026
Test Series
UGC NET img
Teaching
UGC NET (Paper 2) 2026 Mock Test Series
796 Tests 2 Tests Free
219 Attempts
4.4(46)
English
More Questions from UGC NET

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App