

































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
In this document topics covered which are Tree, Binary tree, Strictly binary tree, Strictly binary tree, Implementation, Array Implementation of Binary tree.
Typology: Study notes
1 / 41
This page cannot be seen from the preview
Don't miss anything!


































Def: A tree is a finite set of one or more
nodes such that
(i) There is a specially designated node
called root.
(ii) The remaining nodes are partitioned into
n ≥ 0 disjoint sets T 1
2
k
where
each of these sets is a tree.T
1
2
k
are called subtrees of the root.
A binary tree is a finite set of elements that is
either empty or is partitioned into three
disjoint subsets.The first subset contains a
single element called root of the tree. The
other two subsets are themselves binary
trees called left subtree and right subtree.
A left or right subtree may be empty.
If every non leaf node in a binary tree has
nonempty left and nonempty right subtree,
then binary tree is called
strictly binary tree.
Level – level of root is defined to be zero
level of any other node is defined as one
more than the level of its father.
Depth: maximum level of any node in a
tree is called depth of the tree.
Siblings: nodes with the same father are
called siblings.
Leaves: nodes with no children
Path: is a list of distinct vertices in which
successive vertices are connected by
edges in the tree.
A binary tree can be implemented as an
array of nodes or a linked list.
Array implementation is done by
sequential numbering.
Start numbering from the root.
Then number the nodes of the next level
from left to right, numbering missing nodes
also
This representation can be used for all
binary trees though in most cases there
will be a lot of unutilized space.
For complete binary trees, this
representation is ideal as no space is
wasted.
is utilized.
The most common and easiest way to
implement a binary tree is to represent a
node as a structure consisting of the data
and two pointers
These pointers point to two children of the
binary tree.
manner.
Traversal means visit each node exactly
once.
nodes of a tree in a certain order.
This traversal is used at no. of places:
Searching,
Complier uses it in scanning , parsing,
code generation and arithmetic expression
evaluation.
Preorder traversal
Inorder traversal
A
B
C
D E
G
F
R
T
L
T
Preorder traversal of T process A then traverses left subtree
L
T
and finally traverses right subtree R
L.
The preorder of L
T
processes its root B and then D and E. The preorder of R
T