What is the definition for the height of a tree?

前端 未结 7 449
南旧
南旧 2020-12-09 16:43

I can\'t seem to find a definitive answer for this, I\'m trying to do some elementary proofs on heaps but here\'s what\'s throwing me off a little bit:

Is an empt

7条回答
  •  离开以前
    2020-12-09 17:25

    Height of a tree is the length of the path from root of that tree to its farthest node (i.e. leaf node farthest from the root).

    A tree with only root node has height 0 and a tree with zero nodes would be considered as empty. An empty tree has height of -1. Please check this.

    I hope this helps.

提交回复
热议问题