Maximum and Minimum number of nodes in a heap

As a heap is a complete binary tree with some extra properties, so the same reasoning given in the previous section would apply and we would get the following:

nmax = 2^(h+1) - 1

nmin = 2^(h)

 

For code,

 
To calculate depth of a tree, you can follow the link:

https://www.commudle.com/labs/quickstart-trees-with-four-algorithms/steps/79855

As depth and height concept is already explained, so the above code can be tweaked for height calculation.

Discussion

3

0