Professional Documents
Culture Documents
09 Binary Trees - 2
09 Binary Trees - 2
d
g
e
h
f
i
l
3
b
d
is at depth zero
e is at depth 2
a
Balance
a
b
d
c
e
b
c
h i
j
A balanced binary tree
e
f
i j
An unbalanced binary tree
Using a binary
search tree
lo = 2;
(2+2)/2=2
7 11 13 17
13
5
11 17
6
Tree traversals
Preorder traversal
Inorder traversal
Postorder traversal
10
preorder
inorder
postorder
C
E
ABDECFG
B
G
C
E
D B EAF C G
C
E
DEBFGCA
11
12
Other traversals
That is, the right subtree is traversed before the left subtree
is traversed
13
The End
14