Heapsort 6.1-1

Problem:
What are the minimum and maximum numbers of elements in a heap of height h?

My answer:
The height of a node in a heap is the number of edges of the longest simple path from the node downward to a leaf, so the height of a heap is the height of its root.

When a heap of height h is a full binary tree, it has the maximum number of elements, which is 2^(h+1)-1.
And the minimum number of a heap with height h is 2^(h).   
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章