$2^h-1$ is the inner nodes and also that is construed according to the understood fact. But since nowhere except CLRS mentions heaps to it is in a Nearly finish Binary Tree anywhere it is pointed out as a complete Binary Tree.
You are watching: What are the minimum and maximum number of elements in a heap of height h?
The maximum number of elements have the right to be quickly computed:$$sum_i=0^h 2^i = 2^h+1-1$$
But i cannot get the allude of computing the minimum number of elements:Should the be:$$2^h+1$$ because that $0$ or $2$ youngsters property
Or need to it be:$$2^h$$ for $0$ or $1$ children property
algorithms binary-trees heaps
enhance this inquiry
asked Jun 19 "20 in ~ 9:20
Sachin BahukhandiSachin Bahukhandi
23722 silver- badges1111 bronze badges
add a comment |
2 answer 2
energetic oldest Votes
A heap of elevation $h$ is complete up to the level in ~ depth $h-1$ and also needs to have at least one node ~ above level $h$.
Therefore the minimum total number of nodes have to be at least$sum_i=0^h-1 2^i + 1 = 2^h-1 + 1= 2^h.$, and this tight due to the fact that an heap with $2^h$ nodes has height $h$.
boost this prize
reply Jun 19 "20 in ~ 11:32
19.7k22 yellow badges1818 silver- badges3737 bronze title
include a comment |
I know there"s currently an welcomed answer, yet for those who"ve got the exact same question and also are still a little bit perplexed (as i was), or sth is unclear, clock this crystal clearexplanation till the end.
improve this price
answered might 12 in ~ 17:44
Aarush AggarwalAarush Aggarwal
2111 gold badge11 silver- badge33 bronze badges
add a comment |
Thanks because that contributing response to computer system Science stack Exchange!Please be certain to answer the question. Provide details and also share her research!
But avoid …Asking because that help, clarification, or responding to various other answers.Making statements based upon opinion; earlier them up with referrals or an individual experience.
Use MathJax to style equations. MathJax reference.
To find out more, see our tips on writing an excellent answers.
See more: Can A Remington 870 Express Shoot Slugs ? Can You Shoot Slugs With A Stock 870 Express
Sign increase or log in in
authorize up making use of Google
authorize up using Facebook
authorize up using Email and Password
Post as a guest
email Required, but never shown
Post as a guest
Required, yet never shown
short article Your prize Discard
Not the price you're feather for? Browse other questions tagged algorithms binary-trees heaps or ask your very own question.
Featured ~ above Meta
Increase-key and decrease-key in a binary min-heap
deserve to minimum or maximum elevation of the binary search tree be constrained by the place of some facets
Facts about internal and also external path lengths the binary tree
deserve to a heap have no elements?
The height of subtree in Heap
Is there a surname for this priority queue data structure?
Prove number of nodes in heap
identify minimum and maximum variety of leaves on a complete tree
walk the heap home in the meaning of binary heaps use recursively?
warm Network concerns much more hot questions
subscribe to RSS
concern feed To subscribe to this RSS feed, copy and paste this URL right into your RSS reader.
ridge Exchange Network
site style / logo design © 2021 stack Exchange Inc; user contributions licensed under cc by-sa. Rev2021.11.5.40661