GATE Computer ScienceHardGATE CS (PYQ pattern)

A grammar in Chomsky normal form (no ε-productions) derives a string of length 15. Let N be the number of derivation steps and H the minimum possible height of its parse tree (height = number of edges on the longest root-to-leaf path, leaves being terminals). What are N and H?

  1. A. N = 29, H = 5
  2. B. N = 29, H = 4
  3. C. N = 30, H = 5
  4. D. N = 15, H = 4

Correct answer: A. N = 29, H = 5

Each terminal needs one A → a step (15) and building 15 variable-leaves from one root needs 14 A → BC steps: N = 29. The A → BC part is a binary tree with 15 leaves, whose depth is at least ⌈log₂ 15⌉ = 4; one more edge reaches the terminal, so H = 5 (4 forgets the terminal edge).

More Theory of Computation questions

Exams that ask this topic