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

Discussion

What is the height of a binary tree with 7 nodes ?

  • A.3
  • B.4
  • C.2
  • D.7

Answer: A

The key gives 3.

Seven nodes fill a complete binary tree exactly: 1 node at the root, 2 on the next level and 4 on the last. That is 3 levels, and counting levels, the height is 3, which is how the key reads the question.

\[ 1 + 2 + 4 = 7 \]

Counting edges instead, the same tree has height 2, which is option C, and a skewed 7-node tree would be taller still. The paper states neither a convention nor the shape of the tree, so the item is loose. The key gives A, so it is kept; note that textbooks that define height as the number of edges on the longest path give 2 for the complete tree. Option D, 7, is only the height of a degenerate chain counted in nodes, and 4 fits no 7-node complete tree.

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

Post your comment

Please log in or register to post a comment.