0% found this document useful (0 votes)
36 views4 pages

Unit 2 Tree

A tree is a hierarchical data structure representing parent-child relationships. Key terminology includes root node, parent node, child node, leaf node, ancestor, descendant, sibling, level, degree, and height. A binary tree is a specific type of tree with at most two children, and there are methods to convert a general tree into a binary tree.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views4 pages

Unit 2 Tree

A tree is a hierarchical data structure representing parent-child relationships. Key terminology includes root node, parent node, child node, leaf node, ancestor, descendant, sibling, level, degree, and height. A binary tree is a specific type of tree with at most two children, and there are methods to convert a general tree into a binary tree.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

TREE

what is Tree ????

Tree data structure is a hierarchical structure that is used to represent and


organize data in the form of parent child relationship.

y
Basic Terminology
Ro fig 1.1

1. Root Node : It is the top Most node of tree or the node which does not have any
am
parent node is called as root node eg. Node A
2. Parent Node : The node which is an immediate predecessor of a node is called
the parent node of that node eg. Node A,B,C,D,E
3. Child Node : The node which is the immediate successor of a node is called the
child node of that node. eg.B,C,D,E,F,G,H,I
4. Leaf Node or External Node: The nodes which do not have any child nodes are
ig

called leaf nodes. eg. H,I,J,F,G


5. Ancestor of a Node: Any predecessor nodes on the path of the root to that
node are called Ancestors of that node.
6. Descendant: A node x is a descendant of another node y if and only if y is an
N

ancestor of x.
7. Sibling: Children of the same parent node are called siblings. eg. H,I
8. Level of a node: The count of edges on the path from the root node to that
node
9. Degree of the Node : Number of child nodes attached to a particular node is
called as degree of that node
10. Degree of the Tree : The node with maximum number of children is the degree
of that tree
11. Height of the Tree : The height of of the tree is maximum level of the tree
Binary Tree
The Tree with at most two children is called as binary tree referred to as the left child
and the right child.

oy
fig. 1.2

R
m
Properties of Binary Tree

a
1. At each Level ‘I’ , maximum possible nodes are 2^I eg. consider the fig 1.2

g
at level 3 max possible nodes are 2^3 = 8.

i
2. if the height of the tree is h then the maximum number of nodes that are
possible in the tree is :
(2^0 + 2^1 + 2^4 + ............. + 2^h) = 2^(h+1) - 1

N
3. Minimum Number of nodes which are possible is h+1(height+1)
4. If the no. of Node are n in the binary Tree then min possible height of the
of the tree will be h = log(n+1)-1

n = 2^(h+1) -1
n +1 = 2^(h+1)
taking log on both side we get,
log(n+1) = log2^(h+1)
log(n+1) = h+1
h = log(n+1) -1
Convert General Tree into Binary Tree
We can convert the given general tree into equivalent binary tree as follows -
i) The root of general tree becomes the root of the binary tree.
ii) Find the first child node of the node attach it as a left child to the current node in
binary tree.
iii) The right sibling can be attached as a right child of that node.

Q.1

y
-->
Ro i) The root of general tree becomes root of the binary
tree.
am
ii) The first left child becomes left child of the tree.
iii) The right sibling is attached as right child.
ig

Q.2
N

-->

i) The root of general tree becomes root of the binary


tree.
ii) The first left child becomes left child of the tree.
iii) The right sibling is attached as right child.
Q.3

oy
R
am
Q.4

ig
N

You might also like