Introduction To Trees
Introduction To Trees
Definition − A Tree is a connected acyclic undirected graph. There is a unique path between
every pair of vertices in G. A tree with N number of vertices contains (N−1) number of edges.
The vertex which is of 0 degree is called root of the tree. The vertex which is of 1 degree is
called leaf node of the tree and the degree of an internal node is at least 2.
Labeled Trees
Definition − A labeled tree is a tree the vertices of which are assigned unique numbers from 1
to n. Two labeled trees are isomorphic if their graphs are isomorphic and the corresponding
points of the two trees have the same labels.
Example
Unlabeled Trees
Definition − An unlabeled tree is a tree the vertices of which are not assigned any numbers.
Example
Rooted Tree
A rooted tree G is a connected acyclic graph with a special node that is called the root of the
tree and every edge directly or indirectly originates from the root. An ordered rooted tree is a
rooted tree where the children of each internal vertex are ordered. If every internal vertex of a
rooted tree has not more than m children. If every internal vertex of a rooted tree has exactly m
children, it is called a full m-ary tree. If m=2, the rooted tree is called a binary tree.
Binary Search Tree
Binary Search tree is a binary tree which satisfies the following property −
Example
Solution