문제

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

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top