All mock tests are FREE till 31 December — register to save your progress

The maximum yield length of the following CNF CFG is
S → AB
A → CD
B → e
C → a
D → b

Pick an option to check yourself, or open the answer below.

Show answer & explanation

Correct answer: C. 4

Explanation

The longest root-to-leaf path is S → A → C → a. For a CNF parse tree whose longest path has 3 variables, the yield has at most 2³⁻¹ = 4 terminals. This bound is the keyed answer; the only string actually derived, 'abe', has length 3.

More Theory of Computation and Compilers questions