Which of the following statements are true?
- Every left-recursive grammar can be converted to a right-recursive grammar and vice-versa
- All -productions can be removed from any context-free grammar by suitable transformations
- The language generated by a context-free grammar all of whose productions are of the form or (where, is a string of terminals and is a non-terminal), is always regular
- The derivation trees of strings generated by a context-free grammar in Chomsky Normal Form are always binary trees
View worked solution
Answer: C
To determine which statements are true, let us analyze each one individually:
-
Statement I: Every left-recursive grammar can be converted to a right-recursive grammar and vice-versa. (True)
Left-recursion can always be eliminated from a context-free grammar to produce an equivalent grammar with right-recursion (and vice-versa) using standard algorithms, without changing the language generated by the grammar. -
Statement II: All -productions can be removed from any context-free grammar by suitable transformations. (False)
If the language contains the empty string , we cannot completely eliminate all -productions. At least one production of the form (where is the start symbol) must remain to generate the empty string. -
Statement III: The language generated by a context-free grammar all of whose productions are of the form or is always regular. (True)
A grammar with productions restricted to the forms or (where and is a non-terminal) is a right-linear grammar. Right-linear grammars generate exactly the class of regular languages. -
Statement IV: The derivation trees of strings generated by a context-free grammar in Chomsky Normal Form are always binary trees. (True)
In Chomsky Normal Form (CNF), all production rules are of the form or (and possibly ). Consequently, every internal node in the derivation tree has either exactly children (for ) or child (for ). Since no node has more than children, the derivation tree is always a binary tree.
Thus, statements I, III, and IV are true.
Free practice · Your answers on this page are not saved.
