樹的深度(depth)怎麼求?

2015-03-18 12:53 am
書上資料寫著 the depth of a tree is the largest level number of the tree.

可是其他資料有寫著是 樹根到節點最長的距離


A(B,C(d))
depth是 3 還是 2?

那 A binary tree with depth k is called a full binary tree if and only if it has 2^k-1 怎麼解釋?

回答 (3)

2015-03-18 6:21 am
✔ 最佳答案
樹根比樹節重要~~~



樹節20呎高,樹根就需要爪土30呎深 ^^


樁跟不穩,樹不會高~o^
2015-03-26 9:33 am
發問者條問題唔夠清楚
佢想問binary tree既depth(深度)
雖然002號答得難明d, 但佢既答案係正確既(相反, 001就一定錯)
畢竟呢d係唔止中學程度既知識
2015-03-19 10:09 am
A(B,C(D))'s depth = 3
A----------1
B C--------2
D-----3
A binary tree with depth k is called a full binary tree if and only if it has 2^k-1

that mean the terms "full binary tree" = 2^k-1 (k = depth)

imagine that A(B(D,E),C(F,G))'s depth = 3
A------------1
B C---------2
D E F G------3

2^3 - 1 = 7

A,B,C,D,E,F,G sum up = 7 char

it just mean a binary tree can called "full binary tree" when all tree node have 2 leaf


收錄日期: 2021-04-15 18:51:46
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20150317000051KK00053

檢視 Wayback Machine 備份