Chapter 9 Binary Trees
Chap.9 Contents 9.1 Definition of Binary Tree 9.2 Properties of Binary Trees 9.3 The Binary Tree Theorem 9.4 External Path Length 9.5 Traversals of a Binary Tree
9.1 Definition of Binary Tree binary tree t 可為 empty tree 或 包含: 一個 root element, 與兩個不同的 binary trees, 分別叫 t 的 left sub-tree 及 right sub-tree
Binary trees (elements 大小無規定) 1 2 2 3 1 3
Binary search tree (elements 左小右大) 2 1 3
Tri-nary (3-nary) search tree 2 4 1 3 5 What about N-nary search tree(n-元搜尋樹)? It is called B tree.
This is NOT a binary search tree 5 3 7 4 1 9 8 Because 4 is NOT less than 3
9.2 Properties of Binary Trees
level (x), the level of x, is the same as the depth (x). Is height (t) the same as depth(x)? ANS: No. See next page, height(50) is 3. depth(62) is 2.
這暗示我們: Complete binary tree 可用 array來實作. A B C D E R S F G L
9.3 The Binary Tree Theorem
9.4 External Path Length
9.5 Traversals of a Binary Tree
ANS: inOrder FDGBLEARCS postOrder FGDLEBRSCA preOrder ABDFGELCRS breathFirst ABCDERSFGL