B.B. Karki, LSU
2
CSC 3102
Definition and Concepts
A tree consists of a finite set of elements, called
nodes
, and a finite set of directed
lines, called
branches
, that connect the nodes.
Degree of node = Number of branches = Sum of indegree and outdegree branches
Each node can have an indegree of exactly one but
an outdegree of zero, one or more.
Only one predecessor but multiple successors.
The level of the node is its distance from the root. The height of a tree is the level
of the leaf in the longest path from the root plus one.
Height (or depth) = 3
Different nodes:
Parents: A, B, F
Children: B, E, F, C, D, G, H, I
Siblings: {B, E, F}, {C,D}, {G,H,I}
Leaves: C, D, E, G, H, I
Internal nodes: B, F
Path from the root to the leaf I is AFI.
Subtree: any connected structure below the root
BCD, E, FGHI
Recursive definition: A tree is a set of nodes that is either empty or has a designated
node called the root from which hierarchically descend zero or more subtrees, which
are also trees.
B
E
F
C
D
G
H
I
A
Root at level 0
Branch
FI
Branch AF