“n”个元素堆中高度为“h”的节点数的公式为 ceil(n/2^(h+1))。对于这个给定的问题,如图所示,高度为 2 的节点数为 2。
但从公式中,我得到 ceil(19/8) = 3。
有人可以帮我解释一下我的错误吗?
最佳答案
The formula for the number of nodes of height 'h' in an 'n' element heap is given as ceil(n/2^(h+1))
你能提供你的来源吗?
如果这是关于this problem (我从你的照片中假设)。它说:
大小为 n 的堆最多 个 ceil(n/2^(h+1)) 个高度为 h 的节点
关于algorithm - n 元素堆中给定高度 'h' 的节点数不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42567011/