[理工] 資結 Child Node

作者: s9e0ay917 (Meg)   2018-07-05 20:55:29
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
作者: EXPCDR (EXPCDR)   2018-07-06 08:53:00
好怪 通常這樣不會說他有兩個子點吧,不然每個二元樹的node degree就永遠為2了,那就跟Strict 二元樹的定義一樣了我覺得他說B的左子點是empty tree不是在表達他有左子點,就只是在表達他左子點上的位置是放空樹
作者: h90243768 (滷蛋菘)   2018-07-06 00:02:00
Binary tree 可以為空是 文後面有說啊 B的左子樹為空樹
作者: outofyou   2018-07-05 23:45:00
空的左子樹,有問題嗎?
作者: outofyou   2018-07-06 11:58:00
他都刻意只有說children,沒有說child node,二元樹裡degree有0,1,2,3可能,定義好edge要有連node即可會有其他樹在討論時把leaf node的children做考慮,所以要看個別討論的對象及個別定義的方式。
作者: EXPCDR (EXPCDR)   2018-07-06 14:37:00
那個..請問為什麼二元樹degree可能為3
作者: outofyou   2018-07-06 19:23:00
抱歉,我用的定義是有二元樹結構的無向圖中的節點degree參https://en.wikipedia.org/wiki/Tree_(graph_theory)
作者: EXPCDR (EXPCDR)   2018-07-06 22:11:00
二元樹可以為空,空數node數為0,所以A錯他是說所有二元樹的node都有兩個children,注意他不是說children node。但不是所有二元樹都有node,例如空數就沒有node
作者: eggy1018 (羅密歐與豬過夜)   2018-07-07 00:05:00
Binary tree 每個node 一定有兩個childChild 有value 就是node, 沒有就是empty

Links booklink

Contact Us: admin [ a t ] ucptt.com