algorithm - n 元素堆中给定高度 'h' 的节点数不一致

标签 algorithm data-structures tree heap

“n”个元素堆中高度为“h”的节点数的公式为 ceil(n/2^(h+1))。对于这个给定的问题,如图所示,高度为 2 的节点数为 2。 enter image description here

但从公式中,我得到 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/

相关文章:

java - 为什么这个二叉树代码是错误的?

arrays - 查找修改数组以满足条件的最小操作集

image - 平方差和算法如何工作?

mysql - 关注/取消关注组或列表的数据库架构

java - deleteNode 有问题

javascript - 树到深度树的转换

javascript - 如何找到一个对象内多棵树的根

algorithm - 相似性搜索的索引

c - 多维数组模式访问

algorithm - 如何从一个位置找到所有可能可达的数字?