作者s9e0ay917 (Meg)
看板Grad-ProbAsk
标题[理工] 资结 Child Node
时间Thu Jul 5 20:55:29 2018
https://i.imgur.com/DWfMUej.jpg
想问一段叙述
给了一张图片,并详细叙述了以下,
我的问题在於,明明B只有一个child,为什麽他要说B有两个children. 难道"Empty"也算
一个node吗?
Figure 7.2.1:
*****
Node B has two children: Its left child is the empty tree and its right child
is D. (我的问题在这里)
*****
我的疑点是从这个网站的练习题其中一题才有的,另外附上此网站的练习题
Which statement is false? (答案是A,我的疑点在D)
(A) Every binary tree has at least one node
(B) Every non-empty binary tree has exactly one root node
(C) Every non-root node in a binary tree has exactly one parent
(D) Every node in a binary tree has exactly two children
(E) None of the above
他的解释如下:
Look carefully at the definition for a binary tree.
It states that every binary tree is either empty, or it has a root node and tw
o binary trees as children.
So, every binary tree node has two children, but not every binary tree has a n
ode.(看不太懂这句给的结论)
来源:
https://opendsa-server.cs.vt.edu/ODSA/Books/CS3/html/BinaryTree.html#def
initions-and-properties
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 223.140.130.240
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Grad-ProbAsk/M.1530795333.A.E1D.html
※ 编辑: s9e0ay917 (223.140.130.240), 07/05/2018 21:36:26
1F:→ outofyou: 空的左子树,有问题吗?07/05 23:45
B只有一个child node但叙述上说B有2个child node 我的问题在这里
※ 编辑: s9e0ay917 (223.140.130.240), 07/06/2018 00:02:04
2F:→ h90243768: Binary tree 可以为空07/06 00:02
这个明白:) 所以图片的B节点有两个child node,这是正确的吗?
※ 编辑: s9e0ay917 (223.140.130.240), 07/06/2018 00:03:10
3F:→ h90243768: 是 文後面有说啊 B的左子树为空树07/06 00:08
这样的话,B的左子树等於一个节点吗?可是好像不太对><
想请问child node一定要是存在的点吗?
如果不存在,可以说一个Leaf node有两个child node吗?
很抱歉想厘清一些细节观念><很感谢你的回覆
※ 编辑: s9e0ay917 (223.140.130.240), 07/06/2018 00:17:54
※ 编辑: s9e0ay917 (223.140.130.240), 07/06/2018 00:18:19
4F:推 EXPCDR: 好怪 通常这样不会说他有两个子点吧,不然每个二元树的no07/06 08:53
5F:→ EXPCDR: de degree就永远为2了,那就跟Strict 二元树的定义一样了07/06 08:53
6F:推 EXPCDR: 我觉得他说B的左子点是empty tree不是在表达他有左子点, 07/06 08:57
7F:→ EXPCDR: 就只是在表达他左子点上的位置是放空树07/06 08:57
谢谢你的解释,我好像明白你的意思,但这网站有题练习题(我放在这里了),说明每个bi
nary tree上的node,都一定有两个children><
下面的解释说即便没有节点,每个node都会有两个child? 感觉这个网站解释的有点牵强
Which statement is false? (答案是A,我的疑点在D)
(A) Every binary tree has at least one node
(B) Every non-empty binary tree has exactly one root node
(C) Every non-root node in a binary tree has exactly one parent
(D) Every node in a binary tree has exactly two children
(E) None of the above
他的解释如下:
Look carefully at the definition for a binary tree.
It states that every binary tree is either empty, or it has a root node and tw
o binary trees as children.
So, every binary tree node has two children, but not every binary tree has a n
ode.(看不太懂这句给的结论)
※ 编辑: s9e0ay917 (223.136.141.231), 07/06/2018 10:54:45
8F:→ outofyou: 他都刻意只有说children,没有说child node, 07/06 11:58
9F:→ outofyou: 二元树里degree有0,1,2,3可能,定义好edge要有连node即可 07/06 12:06
10F:→ outofyou: 会有其他树在讨论时把leaf node的children做考虑, 07/06 12:07
11F:→ outofyou: 所以要看个别讨论的对象及个别定义的方式。 07/06 12:08
12F:推 EXPCDR: 那个..请问为什麽二元树degree可能为3 07/06 14:37
13F:→ outofyou: 抱歉,我用的定义是有二元树结构的无向图中的节点degree07/06 19:23
15F:推 EXPCDR: 二元树可以为空,空数node数为0,所以A错07/06 22:11
16F:→ EXPCDR: 他是说所有二元树的node都有两个children,注意他不是说c07/06 22:13
17F:→ EXPCDR: hildren node。但不是所有二元树都有node,例如空数就没07/06 22:13
18F:→ EXPCDR: 有node07/06 22:13
很谢谢你的解释!!
19F:→ eggy1018: Binary tree 每个node 一定有两个child07/07 00:05
20F:→ eggy1018: Child 有value 就是node, 没有就是empty07/07 00:06
谢谢你,我了解了:)
※ 编辑: s9e0ay917 (42.77.129.85), 07/09/2018 13:05:17