问题
I have been struggling with this for several hours now, and I can't seem to find the answers here either. (there are many posts about Binary Heap, but I did not this particular problem).
The problem is:
For a Binary Heap with 1492 nodes, the number of nodes of height two is _187_.
I understand that with 1492 nodes, the binary heap has the depth log(1492)/log(2) = 10 height two should have 2^(10-2) nodes which should be 256
Why is the answer 187?
Thank you
回答1:
In case someone needs to know. I found out the formula is n / 2^(h+1), so 1492 / 2^(2+1) = 186.5.
来源:https://stackoverflow.com/questions/22539689/binary-heap-find-number-of-nodes-at-a-height