1
Trees I Trees
I think that I shall never see A poem lovely as a tree
- - J. Kilmer
Trees
- In CS, we look at trees
from the bottom up
Anatomy of a Tree
- Node
– Basic element of the tree – Contains a piece of information – Represented by the circles a b c d e f g h i j
Anatomy of a Tree
- Child
– Direct descendant of a node – Node a has 2 children: b and c – A node may have multiple children
- Parent
– Direct ancestor of a node – The parent of node b and c are Node a – A node can have only 1 parent
a b c d e f g h i j
Anatomy of a Tree
- Sibling
– Nodes that share the same parent – Nodes b and c are siblings
- Leaf