完整和几乎完整的二叉树之间的区别 [英] difference between complete and almost complete binary tree
问题描述
完整树是其中每个级别都已完全填充的树,而几乎完整树是其中如果最后一个级别未完全填充则所有节点的树尽可能远。我的困惑是在下面的二叉树示例中:
A complete tree is a tree in which every level is completely filled and an Almost complete tree is a tree in which if last level is not completely filled then all nodes are as far as left as possible. my confusion is in following example of binary tree:
O
/ \
O O
/ \ / \
O O O O
/ \
O O
根据定义,它应该是不完整的二叉树,但是它是完整的 二叉树。如果有人可以详细说明这是完整的二叉树,为什么不完整的二叉树呢?
According to definition it should be an incomplete binary tree but it is a complete binary tree. if someone could elaborate how is this complete binary tree and why not an incomplete binary tree?
推荐答案
您的示例是完整的二叉树:完整的二叉树可以具有不完整的最后一级,只要所有叶子
Your example is a complete binary tree: a complete binary tree can have an incomplete last level, as long as all the leaves in it are pushed across to the left.
完美二叉树是一个完整的二叉树,其中最后一个级别已满。
A perfect binary tree is a complete binary tree in which the last level is full.
几乎完整的二叉树是完整但不是完美的二叉树。因此,您的示例也几乎完整。
An almost complete binary tree is a complete but not perfect binary tree. So your example is also almost complete.
术语令人困惑,但是几乎完整的二叉树也完整。
The terminology is confusing, but an almost complete binary tree is also complete.
这篇关于完整和几乎完整的二叉树之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!