Binary Tree Height

后端 未结 8 2081
迷失自我
迷失自我 2020-12-29 12:34

I need a general formula to calculate the minimum height of the binary tree and the maximum height of the binary tree. (not the binary search tree)

8条回答
  •  清歌不尽
    2020-12-29 13:23

    With n-nodes the possible maximum height is floor(log(n)) = ceil (log(n+1))-1.

    With n-nodes the possible minimum height is n-1.

提交回复
热议问题