Consider the following grammar where is the start symbol, and and are terminal symbols.
Which of the following statements is/are true?
View worked solution
Answer: A;B;C
Let us analyze each option step-by-step:
-
Options A and B:
A grammar is ambiguous if there exists a string with more than one distinct leftmost derivation (or parse tree). Let us find the leftmost derivations (LMD) for the string :
- LMD 1:
- LMD 2:
-
Option C:
To generate the string , the derivation must start with .
To match the prefix and the subsequent , the only valid partition is for the first to derive and the second to derive (since any other choice leads to too many terminals or mismatched prefixes).
The unique rightmost derivation (RMD) is: Since there is only one rightmost derivation for , Option C is TRUE. - Option D: The given grammar is a Context-Free Grammar (CFG). The language generated by any CFG is a Context-Free Language (CFL), which is always decidable. Thus, Option D is FALSE.
Free practice · Your answers on this page are not saved.
