General Tree: 1 Mitra Kabir, Dept. of CSE, DU
General Tree: 1 Mitra Kabir, Dept. of CSE, DU
A general tree (a tree) is defined to be a nonempty finite set T of elements, called nodes
such that
(2) The remaining elements of T form an ordered collection of zero or more disjoint trees
T1, T2,…..Tm.
• The trees T1, T2,….Tm are called subtrees of root R and the roots of T1, T2,…Tm are
called successors of R.
A
• Example:
B C D
E F G H I J
Figure: General Tree
K
Mitra Kabir,Dept. of CSE, DU 2
Difference between General Tree and Binary Tree
(2) Suppose a node N has only one child. Then the child is identified as a left child or
right child in binary tree T’, but no such distinction exists in a general tree T.
Example:
Tree T1 Tree T2
3 G 0 0
• Here K is the location of node N of T. K 0 0
4
5 E 0 9
• Here ROOT is used as the root of T.
6 A 2 0
• Example: 7 I 0 12
A
8
B 9 F 0 0
C D
10
E F G H I J 11 H 4 7
ROOT 6
12 J 0 0
K
13 D 11 0
Figure: General Tree and Its Memory Representation
Mitra Kabir,Dept. of CSE, DU 4
Correspondence between General Tree and Binary Tree
(1) The root of T’ will be the root of T.
(2) The left child of N’ in T’ will be the first child of node N in T and the right child of
N’ in T’ will be the next sibling of N in T.
K I
J
Mitra Kabir,Dept. of CSE, DU 5
END!!!