有人可以解释n/(2^(h+1))
用来查找高度为h的节点数的方程吗?
使用三节点树:
4 h=1
2 3 h=0
对于h = 0 = 2个节点,等式给出3 /(2 ^(0 + 1))= 3/2 ^ 1 = 1.5
那是什么意思?这怎么正确,方程式不应该给出高度为0的最大节点数吗,即2,而不是1.5?
此等式来自算法简介http://mitpress.mit.edu/books/introduction-algorithms
以下是有关方程更多的信息,而且我发现它提到:https://cs.stackexchange.com/questions/6405/maximum-number-of-nodes-with-height-h HTTPS://engineering.purdue .edu /〜ee608 / handouts / hw4s.pdf#5
您看错了公式。这不只是ñ / 2 ^ h +1,这是⌈ ñ / 2 ^ h +1 ⌉(方括号没有“脚”是天花板函数,它返回大于它的参数更大的最小整数符号)。
ceil(3/2^(0+1)) = ceil(3/2)
= ceil(1.5)
= 2
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句