前面我們提過了 decision tree 這個東西,今天來提一下 tree structure
來為接下來的 heap sort 做準備
example of a tree
non-tree
A tree data structure that each node has most two children node.
These children are usually refered to as the left child and right child.
樹狀結構的 parent node 至多有兩個 child node 則稱作二元樹(Binary tree),child node 分別稱為左節點(left child)與右節點(right child)
Complete binary tree
A complete binary tree is a binary tree in which all levels are fully filled except the last, and all nodes are as far left as possible.
除了最底層的節點未完全填滿,且最底層節點盡可能向左靠攏的二元樹又可稱為 complete binary tree
Full binary tree
A full binary tree is a binary tree where every node has either 0 or 2 children(no nodes have only one child)
除了最底層節點沒有子節點外,其他節點均有零或兩個子節點的二元樹又可稱為 full binary tree
A tree data structure that each node has most three children node.
These children are usually refered to as the left child , middle child and right child.
樹狀結構的 parent node 至多有三個 child node 則稱作三元樹(Binary tree),child node 分別稱為左節點(left child),中節點(middle child)與右節點(right child)
A ternary tree of size 10 and height 2
以下圖為高度2層,大小為10的三元樹
Tree
https://en.wikipedia.org/wiki/Tree_(abstract_data_type)
Trees In Data Structure
https://www.youtube.com/watch?v=9oTV7fDEaCY
ternary tree
https://en.wikipedia.org/wiki/Ternary_tree
full binary tree vs complete binary tree
https://www.javatpoint.com/full-binary-tree-vs-complete-binary-tree