Machine-translated by Google. Questions are authored in English.
Top

Discussion

A parse tree with n leaves for a grammar in which every production has exactly two symbols on the right has

  • A.two n internal nodes in every possible case
  • B.a number of internal nodes that cannot be determined
  • C.n minus 1 internal nodes
  • D.n internal nodes, one for each leaf of the tree

Answer: C

Each internal node combines two subtrees into one, reducing the count by one. Starting from n leaves and ending at a single root therefore requires exactly n minus 1 combinations. The same identity underlies the node count of any full binary tree.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.