What are the minimum and maximum numbers of elements in a heap of height h?
Answer
A heap of height h has the maximum number of elements when all h+1 floors are full. This is given by the summation:
On the other hand it has the minimum number of elements when the last floor has 1 node. This is given by:
so being n the number of nodes in a heap of height h
No comments:
Post a Comment