Binary Tree Terminology Linear versus hierarchical data Tree – connected graph with no cycles Child Parent Descendant Sibling Ancestor Leaf vs. internal node Level Height Binary / K-ary
Binary Tree - More Terminology Full – Theorem: The number of leaf nodes in a non-empty full binary tree is one more than the number of internal nodes – Theorem: The number of pointers in a non-empty binary tree is one more than the number of internal nodes Complete Ordered Skewed Tree
Arithmetic expression tree (8 + 1) * 3 /((9 – 5) + 2) + (0 * (7 – 4) + 6) + + +* + / *
Traversals Pre-order – Visit – TravelLeft – TravelRight In-order – TravelLeft – Visit – TravelRight Post-order – TravelLeft – TravelRight – Visit
Pre-order Traversal of expression tree +/* * * + / *
In-order Traversal of expression tree 8+1*3/ * * + / *
Post-order Traversal of expression tree 81+3*95-2+/074-* * + / *