All mock tests are FREE till 31 December — register to save your progress
Unit 8 · Theory of Computation and Compilers Paper 2 CS · June 2024 (Re-Exam)

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?

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. {z,x}

Explanation

From Q → RS, FOLLOW(R) includes FIRST(S) − ε = {z}. Since S can be ε, FOLLOW(R) also includes FOLLOW(Q), and from T → Qx, FOLLOW(Q) = {x}. So FOLLOW(R) = {z, x}.

More Theory of Computation and Compilers questions