edited by
4,515 views
4 4 votes

Linked Answer Questions: Q. 80 to Q. 81 .
Consider the following grammar production
\[
\begin{array}{l}
\mathrm{S} \rightarrow \mathrm{BB} \\
\mathrm{~B} \rightarrow \mathrm{aB} \mid \mathrm{b}
\end{array}
\]
Q. 80 LR(1) item [ $B \rightarrow a \cdot B, a]$ is a valid for which of the following viable prefix?
(a) a
(b) aa
(c) aaa
(d) Baa
Q. 81 LR(1) item $[B \rightarrow a \cdot B, S]$ is a valid for which of the following viable prefix?
(a) a
(b) Baa
(c) $a a B$
(d) Bab

Linked Answer Questions: Q. 82 to Q.83.
(b) Even Positive Inte
(c) Even and Odd bs
(d) None of these

Linked Answer Questi
Consider a system segmentation. The virtus of up to 8 segments an bytes long. The hardw into $2^{8}$ byte pages.
Q. 84 How many bits the segment nu
(a) 1 bit
(c) 3 bits

Consider the algorithm below

3 Answers

5 5 votes

80 . LR(1) item B---> a.B,a  is valid for " aaa ". 

 A---> a'.ß, a'' is valid for viable prefix let y if there is derivation S-rm*-->ØAw---> Øa'ßa''w

here y=Øa' here a'' is lookahead , which is first symbol of w so for given question 

S--> BB---> BaB--->--> Bab---> aBab-*-->aaaBab(rightmost derivation)  so here a''=a , w=ab ,Ø=aa,

viable prefix = aaa 

81. similar here S--> BB --> BaB--> BaaB 

so w=∊ ,a''=$  ,a'=a , Ø=Ba so

y=  Baa..

reference http://www.cs.clemson.edu/course/cpsc827/material/LRk/LR1.pdf

http://tinman.cs.gsu.edu/~raj/4340/sp12/LR1.pdf

1 1 vote

Viable prefix : The prefixes of right sentential forms that can appear on the stack of a shift-reduce parser are called viable prefixes.

Simple design LR(1) DFA. then u get the ans. Ans will be d and b respectively.

follow this : http://www.cs.cornell.edu/courses/cs412/2007sp/lectures/lec09.pdf

edited by
1 1 vote
answer  is option ( c ) aaa

so in B-->a.B,a            a    after ,   is   lookahead   

by   deriving stings  we  have to check rightmost derivation

since vaid  viable prefix for item B-->a.B,a   will   be  'y'  in  S==> yBx   such that there is a  RMD  in which  x  should have starting symbol as   ' a ' (  corresponds to lookahead symbol)

so  according to given derivation-->

S==>BB==>aBB==>aBaB==>aaBaB==>aaaBaB==>aaaBab      here   y=aaa  ,    B=B   ,   x=ab   and  starting symbol of x is ' a ' .

which is given in option is also   ( c ) aaa.

hence answer  is option ( c ) aaa
Position:
Show:

Related questions

2 2 votes
1 1 answer
4.1k
4.1k views
KISHALAY DAS asked Nov 12, 2016
4,082 views
Consider the augmented grammar :\[\begin{array}{l}\mathrm{S}^{\prime} \rightarrow \mathrm{S} \\\mathrm{~S} \rightarrow \mathrm{aSa}|\mathrm{bSb}| \mathrm{aSb}|\mathrm{ab}...
1 1 vote
0 0 answers
637
637 views
Ayush Upadhyaya asked Dec 12, 2018
637 views
I have one doubt regarding getting viable prefixes for a grammar. Suppose I am given a grammar G which is told to be LR(0).I have observed, if I draw LR(0) DFA for it, an...
4 4 votes
2 2 answers
2.4k
2.4k views
Anusha Motamarri asked Sep 30, 2016
2,441 views
i think "(E+F*" is viable prefix but "E+F*" is not viable prefix. correct?
4 4 votes
2 2 answers
17.8k
17.8k views
Suvam Chatterjee asked Sep 28, 2015
17,758 views
Can someone describe what is a viable prefix with an example?