The Gateway to Computer Science Excellence
+14 votes

Consider the following grammar:

  • $P\rightarrow xQRS$
  • $Q\rightarrow yz\mid z$
  • $R\rightarrow w\mid \varepsilon$
  • $S\rightarrow y$

What is FOLLOW($Q$)?

  1. $\left \{ R \right \}$              
  2. $\left \{ w \right \}$                
  3. $\left \{ w,y \right \}$                   
  4. $\left \{ w,\$ \right \}$
in Compiler Design by Veteran (431k points)
edited by | 2.2k views

7 Answers

+19 votes
Best answer

Follow of $Q$ is first of $R$ so we get $\{w\}$

but since $R$ can be Null so we have to check first of $S$ which is $\{y\}$

so FOLLOW $Q=\{w,y\}$

Correct option (C)

by Active (3.4k points)
edited by
+8 votes

correct option is c.

by Loyal (8k points)
could u plz tell me how to insert a picture in this
Nice explanation. From this answer Follow set find rules can be verified.
+5 votes
  First Follow
P {x} {$}
Q {y,z} {w,y}
R {w,ε} {y}
S {y} {$}

Ans: (C) - {w,y}

by Junior (517 points)
+3 votes

so C is ans.

by Loyal (6.8k points)
–1 vote
c is correct
by Active (4k points)
–1 vote
Ans option d
by (419 points)
answer d is not correct because for Follow of Q we have to find first of R and there is epsilon move in first of R so by putting epsilon in P now we have to find first of S hence option C
so plz correct ur answer
–1 vote
option C
by (443 points)

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,385 answers
105,369 users