Question

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

Was it helpful?

Solution

In case someone needs to know. I found out the formula is n / 2^(h+1), so 1492 / 2^(2+1) = 186.5.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top