Skip to content
Official PYQ · 2008

GATE CS 2008 Q50 — Parsing (LL, LR)

Explain with AI

Which of the following statements are true?

  1. Every left-recursive grammar can be converted to a right-recursive grammar and vice-versa
  2. All ϵ\epsilon-productions can be removed from any context-free grammar by suitable transformations
  3. The language generated by a context-free grammar all of whose productions are of the form X→wX \rightarrow w or X→wYX \rightarrow wY (where, ww is a string of terminals and YY is a non-terminal), is always regular
  4. The derivation trees of strings generated by a context-free grammar in Chomsky Normal Form are always binary trees
Choose one option
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 ϵ\epsilon-productions can be removed from any context-free grammar by suitable transformations. (False)
    If the language L(G)L(G) contains the empty string ϵ\epsilon, we cannot completely eliminate all ϵ\epsilon-productions. At least one production of the form S→ϵS \rightarrow \epsilon (where SS 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 X→wX \rightarrow w or X→wYX \rightarrow wY is always regular. (True)
    A grammar with productions restricted to the forms X→wX \rightarrow w or X→wYX \rightarrow wY (where w∈Σ∗w \in \Sigma^* and YY 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 A→BCA \rightarrow BC or A→aA \rightarrow a (and possibly S→ϵS \rightarrow \epsilon). Consequently, every internal node in the derivation tree has either exactly 22 children (for A→BCA \rightarrow BC) or 11 child (for A→aA \rightarrow a). Since no node has more than 22 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.

Published
Report a correction
Keep exploringMore Parsing (LL, LR) questions