树节点可以既是根节点又是叶节点吗?
Can a tree node be both a root node and a leaf node?
一个树节点可以既是根节点又是叶节点吗?如果是,为什么?
我知道根节点在树的第 0 层。我也明白叶节点是没有children的树节点。因此,如果一棵树只有一个根节点 A
而没有其他节点,那么该根节点 A
是否也被视为叶节点?
树节点是否可以既是根节点又是叶节点?
If a tree node can have both a root node and leaf node, why
如果一个节点在根和叶之间的某处,它下面既有根节点也有叶。
how is it possible for a tree node to be both a root node and leaf node?
如果树只包含一个节点,则该节点既是根又是叶。
从这个 Wikipedia link 关于树数据结构,树中使用的术语部分:
Root – 树中的顶级节点。
叶子 – 没有 children 的节点。
因此根据定义,如果树结构 仅 由单个节点组成,则该单个节点实际上既是根又是叶。阅读 link 了解更多详情。
现在,您的教授是否认为这是正确的完全是另一回事了。
If a tree node can have both a root node and leaf node, why?
您回答了自己的问题:
I understand that the root node is at Level 0 of the tree. I also understand that a leaf node is a tree node that has no children.
这里有一张图表可以更好地理解:
root
|
tree node
|
leaf node
So if a tree node had a root node of A and nothing else, would that be considered a leaf node also?
直接参考上面的定义。更好理解的图表:
A - root node
|
tree node <-- tree node & leaf node
|
(null)
It is possible and how is it possible for a tree node to be both a root node and leaf node?
如果将根节点视为树节点,则没有子节点的根节点既是树节点又是叶节点。
一个树节点可以既是根节点又是叶节点吗?如果是,为什么?
我知道根节点在树的第 0 层。我也明白叶节点是没有children的树节点。因此,如果一棵树只有一个根节点 A
而没有其他节点,那么该根节点 A
是否也被视为叶节点?
树节点是否可以既是根节点又是叶节点?
If a tree node can have both a root node and leaf node, why
如果一个节点在根和叶之间的某处,它下面既有根节点也有叶。
how is it possible for a tree node to be both a root node and leaf node?
如果树只包含一个节点,则该节点既是根又是叶。
从这个 Wikipedia link 关于树数据结构,树中使用的术语部分:
因此根据定义,如果树结构 仅 由单个节点组成,则该单个节点实际上既是根又是叶。阅读 link 了解更多详情。
现在,您的教授是否认为这是正确的完全是另一回事了。
If a tree node can have both a root node and leaf node, why?
您回答了自己的问题:
I understand that the root node is at Level 0 of the tree. I also understand that a leaf node is a tree node that has no children.
这里有一张图表可以更好地理解:
root
|
tree node
|
leaf node
So if a tree node had a root node of A and nothing else, would that be considered a leaf node also?
直接参考上面的定义。更好理解的图表:
A - root node
|
tree node <-- tree node & leaf node
|
(null)
It is possible and how is it possible for a tree node to be both a root node and leaf node?
如果将根节点视为树节点,则没有子节点的根节点既是树节点又是叶节点。