Grad-ProbAsk 板


LINE

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/m.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
14F:→ outofyou: 參https://en.wikipedia.org/wiki/Tree_(graph_theory) 07/06 19:28
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







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:WOW站內搜尋

TOP