一棵树的高度的定义是什么? [英] What is the definition for the height of a tree?
问题描述
我似乎无法为此找到明确的答案,我正在尝试对堆进行一些基本的证明,但以下是让我有点失望的原因:
I can't seem to find a definitive answer for this, I'm trying to do some elementary proofs on heaps but here's what's throwing me off a little bit:
空树有效吗?如果是,它的高度是多少?
我认为这将是 0.
Is an empty tree valid? If so, what is its height?
I would think this would be 0.
单节点树的高度是多少?
我认为这将是 1,但我已经看到它为 0 的定义(如果是这种情况,那么我不知道如何解释空树).
What is the height of a tree with a single node?
I would think this would be 1 but I have seen definitions where it is 0 (and if this is the case then I don't know how to account for an empty tree).
推荐答案
我认为你应该看看 NIST 网站上的算法和数据结构词典.高度定义 表示单个节点的高度为 0.
I think you should take a look at the Dictionary of Algorithms and Data Structures at the NIST website. There definition for height says a single node is height 0.
有效树的定义确实包含空结构.网站没有提到这种树的高度,但根据高度的定义,它也应该是0.
The definition of a valid tree does include an empty structure. The site doesn't mention the height of such a tree, but based on the definition of the height, it should also be 0.
这篇关于一棵树的高度的定义是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!