最大堆和二叉树
这是我的数据结构书中的一个例子,在这个练习中,它不是最大堆,但它没有说明它的原因,请帮助我,为什么它不是最大堆,谢谢。
35
/ \
/ \
27 28
/ \ / \
/ \ / \
14 16 20 19
this is an example in my data structure book and for this exercise was written that this is not a max heap,but it doesn't say its reason would you please help me that why it is not a max heap thanks.
35
/ \
/ \
27 28
/ \ / \
/ \ / \
14 16 20 19
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是堆树,但是这本书写错了。不要遵循这本书。
This is a heap tree, but this book is written wrong. Do not follow this book.
我认为(最大)堆的定义是每个节点都大于其所有子节点。因此,最大值始终位于根部,因此易于访问。这对我来说看起来像一堆!
I thought the definition of a (max) heap is that every node is bigger than all its children. And, therefore, the largest value is always at the root and therefore easy to access. This looks like a heap to me!
你应该发布整个问题,如果那本书实际上说这不是最大堆,那么就停止阅读那本书:P
you should post the entire question, and if that book actually says that this is not a max-heap then stop reading that book :P