What is tree
Definition:- Tree is is hierarchical (or non-linear) data structure.
or
Tree is a finite set of elements that is either empty or partitioned into three disjoint subsets ,the first subset contains a single element called the root of the tree.The other two subset are themselves tree called left and right subtree of original tree .Each element of tree is called a node of the tree .
Important Term related with trees-
Root Node- The First Subset or single element called root or parent node of the tree (Such as A is the root node in above figure)
Leaf Node - The node that has no son is called leaf node of tree (Such as D,E,F,G are the leaf node in above fig)
Sibling- Two nodes are sibling if they have same parent (such as D,E and F,G are siblings)
Level of tree- The level of a node in binary tree is the number of edges traversed from the root node to the node i.e. root has 0 level and level of any other node is one more than the level of its parents (such as level of below tree is 3 )
Depth of Tree- The depth of tree is the maximum level of any leaf in the tree ( such as depth of below tree is 4)
Climbing- Going from the leaves to the root is called "climbing"
Descending - Going from the root to the leaves is called descending
0 comments:
Post a Comment