Q
二叉樹的定義
0
A
回答
0
這取決於你使用二叉樹算法:作爲冰淇淋,有很多味道:)
一個例子是,當你有節點指針和葉指針的節點上的混合,以及當你在一個完整的節點上插入新的值時,決定創建第二個節點(不管是根還是其他節點)的平衡系統:不是創建一個根節點和2個葉節點,通過分割創建另一個節點,創建另一個節點更加經濟節點。
2
正確。樹可以是空的(無)
假設你有兩棵樹:一棵樹有一個頂點,另一棵是空的(無)。他們看起來像這樣:
O .
請注意,我爲(無)樹使用了一個點。
然後我添加一個新的頂點,並從新頂點到現有兩棵樹的邊緣(注意,我們不從現有樹中取出邊並將它們連接到新頂點 - 這是不可能的)。所以,現在看起來它:
O
/\
O .
由於邊緣導致(無)中沒有畫出,這裏是什麼是底:
O
/
O
我希望澄清。
0
維基百科可能是錯誤的。二叉樹是有限的數據結構,必須允許子樹爲空,否則二叉樹將是無限的。遞歸定義二叉樹的基本情況必須允許單個節點或空樹。的Touch of Class: An Introduction to Programming Well Using Objects and Contracts, by Bertrand Meyer, Springer Verlag, 2009. © Bertrand Meyer, 2009. 14.4
部分有二叉樹更好的遞歸定義
Definition: binary tree
A binary tree over G, for an arbitrary data type G, is a finite set of items called
nodes, each containing a value of type G, such that the nodes, if any, are
divided into three disjoint parts:
• A single node, called the root of the binary tree.
• (Recursively) two binary trees over G, called the left subtree and right subtree.
The definition explicitly allows a binary tree to be empty (「the nodes, if any」).
Without this, of course, the recursive definition would lead to an infinite
structure, whereas our binary trees are, as the definition also prescribes, finite.
If not empty, a binary tree always has a root, and may have: no subtree; a
left subtree only; a right subtree only; or both.
相關問題
- 1. 完全二叉樹的定義
- 2. 二叉樹 - 哪一種二叉樹
- 3. 二叉樹到二叉搜索樹(BST)
- 4. 二叉樹中最大的二叉樹搜索樹
- 5. 二叉樹findHeight
- 6. balanced()二叉樹
- 7. 二叉樹
- 8. 二叉樹
- 9. JAVA:二叉樹
- 10. 二叉樹
- 11. 二叉樹
- 12. 非二叉樹
- 13. 二叉樹葉
- 14. Python二叉樹
- 15. 二叉樹值
- 16. OpenMP - 二叉樹
- 17. 二叉樹
- 18. OCaml的二叉樹
- 19. Python的二叉樹
- 20. 是一個二叉樹的二叉樹嗎?
- 21. 從二叉樹實現二叉樹實現的線程
- 22. 設計從二叉樹類繼承的二叉搜索樹類
- 23. 完整二叉樹和平衡二叉樹的區別
- 24. 檢查二叉樹是否爲二叉搜索樹的函數?
- 25. 二叉樹在Javascript
- 26. 打印二叉樹
- 27. 二叉搜索樹
- 28. 二叉樹方法
- 29. 二叉樹方法
- 30. 二叉樹問題