retagged by
560 views
0 votes
0 votes
A grammar that has not any epsilon production and also free from unit productions.The maximum number of reduce moves that can be taken during bottom up evaluation of 25 token string by bottom up parser is____________.
retagged by

1 Answer

0 votes
0 votes

A grammer according to conditions in question would be something like this, 
S→aB
B→bC
C→cd

For a string 'abcd' 


The Right Most Derivation for the above is:
S →aB (Reduction 3)
→abC (Reduction 2)
→abcd (Reduction 1)

We can see here the number of reductions present is 3. And this is maximum.

Why maximum? Unit production could led us to max number of production, which could be equal to 'n'. But since no unit productions, this is max. 

We can get less number of reductions with some other grammar which also doesn’t produce unit or epsilon productions or production of the form A→a:
S→abA
A→ cd

The Right Most Derivation for the above is:
S →abA (Reduction 2)
→abcd (Reduction 1)

Hence 2 reductions.

But we are interested in knowing the maximum number of reductions which comes from the 1st grammar. Hence total 3 reductions as maximum, which is (n – 1) as n = 4 here.

Related questions

443
views
1 answers
0 votes
Rohit Chakraborty asked Oct 6, 2023
443 views
Can anyone draw the transition diagram for this augmented grammar in LR(1) parser?$S’\rightarrow S$S\rightarrow A|B$A\rightarrow fAi|n$B\rightarrow fBii|d$for the above augmented grammar the number of states in LR(1) parser are________.
394
views
1 answers
1 votes
514
views
1 answers
0 votes
469
views
2 answers
0 votes