GATE / CS ARCHIVE

GATE CSE 2008 / QUESTION 50

Grammar transformations and normal-form trees

Theory of Computation · Context-Free Grammars & Languages · Full GATE CSE 2008 paper

GATE 2008, Q50 2 marks · MCQ
Report issue

Context-Free Grammars & Languages

Question 50, GATE 2008: Which statements are true? I: every left-recursive grammar can be converted to a right-recursive grammar and vice versa. II: all ε-productions can be removed from any CFG by suitable transformations. III: a CFG with only X→w or X→wY, where w is a terminal string and Y a nonterminal, always generates a regular language. IV: derivation trees for a CFG in Chomsky normal form are always binary trees.

(A) I,II,III,IV
(B) II,III,IV only
(C) I,III,IV only
(D) I,II,IV only
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Under the conventional grammar-transformation interpretation, I, III and IV are true, giving C. I refers to eliminating left recursion using right-recursive auxiliaries and the symmetric transformation for right recursion; it does not mean every context-free grammar becomes a right-linear regular grammar.
2. II is false as stated: if ε belongs to the language, removing every ε-production cannot preserve that language, since no nonempty sentential form can derive the empty string without one. III is a right-linear grammar, possibly with multi-terminal labels; expanding labels into paths yields a finite automaton, so its language is regular.
3. IV is true in the at-most-two-children sense of binary tree: CNF uses A→BC or A→a (and possibly the special start ε-rule), so no derivation-tree node has more than two children.

Original paper, page 9