Trees
Trees
Trees
.
What is Tree?
Definition: A tree is a data structure which is a collection of
Zero or more nodes and finite set of directed lines called
branches that connects the nodes
Node
In tree data structure, every individual element is called
as Node.
Node in a tree data structure stores the actual data of that
particular element and link to next element in hierarchical
structure.
.
.
Terminology
The node which has a link from its parent node is called as
child node.
In a tree, all the nodes except root are child nodes.
5. Siblings
In a tree data structure, the node which does not have a child
is called as LEAF Node.
In simple words, a leaf is a node with no child.
In a tree data structure, the leaf nodes are also called
as External Nodes. External node is also a node with no child.
In a tree, leaf node is also called as 'Terminal' node.
7. Internal Nodes
In a tree data structure, the node which has at least one child
is called as INTERNAL Node. In simple words, an internal node
is a node with at least one child.
External nodes
8.Degree
Total number of children of a node is called as DEGREE of that Node.
In simple words, the Degree of a node is total number of children it has.
The highest degree of a node among all the nodes in a tree is called as
'Degree of Tree'
In degree and Out degree
9. Level
.
Almost Complete Binary Tree-
An almost complete binary tree is a binary tree that
satisfies the following 2 properties-
◦ All the levels are completely filled except possibly the last
level.
◦ The last level must be strictly filled from left to right.
.
A binary search tree
A binary search tree should satisfy following
2 conditions:
◦ value of all the nodes in the left sub-tree should be
less than or equal to the vale of the root.
◦ The value of all the nodes in the right sub should
be greater than or equal to the value of the root.
Example