(TREE)TREE) Tree Root Node Subtree 1.
(Root node) , RRoot node) , R 2. n T1 , T2 ,..Tn (Root node) , Rn >=0) (Root node) , RSubtree) R A,B,C,D A E,F,G F J B (Level)Level))
1 1 F 4 (Level)Level) Degree) X 1 A 2 H 3 B 1 E 0 (Level)Leaf Node)
0 C, D, E, J, F G 0 interior node branch node Immediate Successor SON i Immediate Successor i i SON H E, I, F Immediate Predecessor father i Immediate Predecessor i
FATHER J I FATHER I H (TREE)Tree Structure) Root Nodes R Nodes X Immediate Predecesso Y X Father (TREE)Parent) C A B
X D H YNodes Y Immediate Successo X Y son (TREE)Child) X Leaf Nodes E I G (TREE)Tree Structure)
Root Nodes R A B D H C Leaf Nodes E I
Level 0 X Level 1 Y Level 2 G Level 3 el Node 1 (TREE)Tree Structure) Root Nodes
R A B D H C Leaf Nodes E I Level 0
X Level 1 Y Level 2 G Level 3 gree Subtree A De Degree 1 (TREE)Tree Structure) Root Nodes
R A B D H C Leaf Nodes E I Level 0
X Level 1 Y Level 2 G Level 3 Node Degree = 0 C, D, E, I ,G Degree <> 0 Branch Node Interior Node (TREE)Tree Structure) R C
A B D H E I Nodes X Immediate Predecesso X Y X Father (TREE)Parent) Nodes Y Immediate Successor Y X Y son (TREE)Child) X
G Predecessor Node Successor Node R, B, H Predecessor E, I, (TREE)Binary Tree) rooted binary tree 2 ( ) (left subtree) (right subtree)
17 (TREE)Binary Trees) <=2 18 Binary Tree 19
Empty Null Tree A C B D V C E F G
D S G () () (), () () F X () () () (), ()
() () (TREE) Complete Binary Tree) ( left son right son ) (leaf nodes) Dn () 3 R K W
O U () M n 2n-1 W V D S A Q
N 23-1 = 7 2 1. 2. (Root node) , Rsequential)
DATA DATA LLINK RLINK LSON RSON LSON RSON 1 complete binary tree 1 2 ...
k 1 1 2 4 C 8 E A B D
9 10 3 6 5 11 12 X 13 7 14 15
4 5 6 7 8 9 10 11 12 13 14 15 1 2 3 A B X C D - - E - - - - - - x 2x Data07 Tree(Level) 28) Tree Binary Tree (Root node) , Rordinary) binary tree 1.
2. 1 Data07 Tree(Level) 29) Tree Binary Tree 1 2 3
4 Data07 Tree(Level) 30) Tree A Binary Tree A B B C F D
E G H C K J L D E G L I
A I F C G D K J H
B 1-3 F E H J K L I (TREE)Tree Traversal) Tree Traversal
3 () 1. Pre-Order Traversal (TREE)RTLTR) 2. In-Order Traversal (TREE)TLRTR) 3. Post-Order Traversal (TREE)TLTRR) Data07 Tree(TREE) 32) Binary Tree 3 1. Inorder traversal Symmetric order
(TREE)Left/ Root/Right) 2. Preorder traversal (TREE)Root/ Left/ (TREE)Binary Tree Traversal) start R stop Pre-Order Traversal (TREE)Root/ Left/ Right A
C X D Y G Result R A C D X
Y G (TREE)Binary Tree Traversal) start R stop In-Order Traversal (TREE)Left/ Root/Righ A C
X D Y G Result C A D R G Y
X (TREE)Binary Tree Traversal) start R stop Post-Order Traversa (TREE)Left/ Right/ Root) A C X D
Y G Result C D A G Y X R
Data07 Tree(TREE) 36) Binary Tree A B C 1. (TREE)Left/ Root/Right) BAC 2. (TREE)Root/ Left/ Right) ABC 3. (TREE)Left/ Right/ Root) BCA A B
D C E F G H I 1. (TREE)Left/ Root/Right) DB A EG C HFI 2. (TREE)Root/ Left/ Right) A B
C D E G H Pre-order : ABDGCEHIF In-order : DGBAHEICF F I EX1
+ - A * B D C 1.Pre-order 3.Post-order 2.In-order Expression Tree operands, operators
Expression tree (Root node) , Ra + b * c) + (Root node) , R(Root node) , Rd * e + f ) * g)) Expression Tree Data07 Tree(Level) 41) (Root node) , Roperand) (Root node) , Roperators) (Root node) , Rleave node) (Root node) , Runary operator) - log)(Root node) , R) cos(Root node) , R)
+ * Z X Y X * Y + Z Expression Tree Data07 Tree(Level) 42) (Root node) , RX (Root node) , R(Root node) , RY / R) * D)) X
* / Y D R X-Y/R*D -X*/YRD Expression Tree 1.
operand tree push stack 3. operator pop stack 2 trees T1 T2 (T1 ) tree (root) operator left right children T1 T2 tree stack 2. a b + c d e + * * 1 2 3 a b + c d e + * * 4
5 a b + c d e + * * 6 7 1. Preorder ,Inorder , Postorder A H B F G
D 2. Expression Tree 2.1 (Root node) , RA - 2 * (Root node) , RB + C) D * E) * F 2.2 A + (Root node) , RB C) * D ^ (Root node) , R E * F ) J I K M 3. A H B
C D F E G J I K M