retagged by
2,013 views
1 votes
1 votes
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
retagged by

2 Answers

0 votes
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.

0 votes
0 votes
In any CFG $G,$ for every $w \in L(G);$ we have:

The number of parse trees of $w$ = The number of LMDs of $w$ = The number of RMDs of $w$.

i.e. For every string $w \in L(G)$, the number of parse trees is same as the number of leftmost derivations & that is same as the number of rightmost derivations.

For every parse tree, there is a unique leftmost, and a unique rightmost derivation. Similarly, for every leftmost derivation, there is a unique parse tree. Similarly, for every rightmost derivation, there is a unique parse tree.

So, answer is Option B, $l = r = p.$
Answer: