retagged by
523 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

0 votes
0 votes
1 answer
1
1 votes
1 votes
1 answer
2
0 votes
0 votes
1 answer
3
0 votes
0 votes
2 answers
4