The Gateway to Computer Science Excellence
0 votes
246 views
Let G be a CFG , l be the number of left most derivations , r be the number of right most derivations and p be the number of parse trees.Assume l , p , r are computed for a particular string . For a given CFG 'G' and given string 'w'. What is the relation between l , p and r

a) l <=p<=r

b)l=p=r

c)l>=p<=r

d)none
in Compiler Design by Boss (10.2k points) | 246 views
+1
For unambiguous grammar b)
0
Please explain.

both lmd and rmd trees are parse trees. For any unambiguous grammar we have unique lmd and rmd. Hence l = r.

and parse trees are l + r.

Correct me if I’m wrong .
0

@anil

L =r   means left most derivation and right most derivation is same

so which means there is only one parse tree possible

so l=p=r

p=L+r

is when its ambiguous and we have more than one left and right most derivations

1 Answer

0 votes

For a particular string, there can be just one Leftmost derivation, and just one Rightmost derivation. So, l = r.

Now, both the derivations translate into the same parse tree. But in case of ambiguous grammars, there can be more than one parse trees. However, RMD and LMD for a particular string remain just one.

Hence, l = r $\leq$ p

So, none of the above.

Option D.

 

Assuming the grammar is unambiguous, Option B.

by Active (2.8k points)
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,645 questions
56,596 answers
195,824 comments
102,073 users