SlideShare a Scribd company logo
v.lavanya
MSC I T
OBJECTIVES
root node is desigated wich has no parent
if the imediate predecessor of the node is parent of the node then all imediate sucessor of a node
are known as child
child which is on left side is called left child and hat on right side is called
right child
Basic terminolgies
Binary tree and operations
BINARY TREES WITH EXAMPLES
PROPERTIES OF BINARY TREE
 the maximum no of nodes
possible in a binary tree of
height h is 2power of h-1
The minimum no of nodes
possible in a binary tree Height
h is h
a binary tree has the minimum
no of nodes one every parent
has one child such kind of
trees are called skew binary
trees
LINEAR ARRAY
NONLINEAR
LINKED LIST
• The root N of T is stored
in TREE [1]. If a node
occupies TREE [k] then its
is stored in TREE
and its is
stored into TREE
Advantage of sequential rpresentation
any node can acessed from any other node by calculating the
index value
data are stored without any pointers to their
which are mentioned implicity
programing lanuage where dynamic memmory allocation is not
possible such as(BASIC ,FORTRAIN)ARRAY
REPREPRESENTAION IS nly means to store a tree
Disadvantage of sequential reprentation
other then the full of binary trees the majority of the array entries
may be empty
it allows only static representation it is in no way possible to
enhance the tree structure if the array size will be limited
insering new node to the tree or deleting a node in a tree data
moved up and moved down in an array excessive amount of
processing time
linked list representation
of a binary tree they are two field s
to stor the address of left child
and right child of the node
data is the current
information of the node
if one knows the address of the root node
then form it other node can be acessed
physical implementation of a binary tree in memmory
Algorithm build a tree
input:ITEM is the data contet of the node i
output: a binary tree with two sub-trees of the node i
data structure: array representation of a binary tree
operations of binary trees
 insertion: TO include a node into an existing binary tree
deletion: TO delete a node from a non-empty binary tree
Traversal: TO visit all the nodes in abinary tree
in traversal they are three orders
inorder -> LEFT->ROOT->RIGHT
preorder -> ROOT->LEFT->RIGHT
postorder-> LEFT->RIGHT->ROOT
merge:TO merge two binary trees into a large one
in this operation to insert a
new node at any position in
a binary tree
we have a simple insertion
for ex to insert a “g “ a new
node
two stops
search the existence node
second establish the link
Binary tree and operations
insert a binary tree using linked list
• insert:KEY is the data content of the key node after new node is
to be inserted an ITEM is the data content of the new node can
be inserted
• output: A node with data component ITEM inserted as an
extrernal node after the node having data KEY if such a node
does not exist with empty (s), that is, eiter child or both children
IS/ARE ABSENT.
• DATA STRUCTURE: linked structure of a binary tree. ROOT is
the pointer to the root node.
Binary tree and operations
algorithm
• PRINT “ insertion is not possible as left child”
• EXIT
• EDIF
• ELSE
• IF(pf->RC =NULL)
• new=GETNODE
• new->DATA=ITEM
• new->LC=new->RC=NULL
• ptr->RC=new
• else
• print”insertion is not possibble as right child”
• exit
• end if
• else
• print”the key node is already has a child”
• stop
deletion
• in deletion operation can be carried out of two kinds of storage
representation of binary trees
• in ordernto delete a node in a binary tree it is required to reach at
the parent node to be deleted
• the link of the parent nodes whih stores the location of the node
to be deleted is then set buy a NULL entry
• input:given ITEM as data of the node with which the node can be
identified for deletion
• output:a binary tree without a node having a data ITEM
• data stucture: array a storing binary trees SIZE denotes the size
of a
Binary tree and operations
WHAT IS A TRAVERSAL?
THE traversal operation is frequently used operation of a binary
this operation to visit each node in the tree exactly once
a full traversal of a binary tree gives a linear ordering of the data
in the tree
if a binary tree contains an arithmetic expression then it traverse
infix notations,posfix notations,prefix notations
preorder traversal
Binary tree and operations
Binary tree and operations
Binary tree and operations
input:two pointers ROOT1 and
ROOT2 OF THE TWO BINARY
TREES t1,t2
output:a binary treee containing all
the node t1,t2 ptr to the root as
ROOT
data structure:linked the data
strucure
steps:
if(ROOT1=NULL)THEN
ROOT=ROOT2
EXIT
Binary tree and operations

More Related Content

PPTX
Binary Tree in Data Structure
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
PPT
Doubly linked list
PPTX
Tree in data structure
PPTX
Threaded Binary Tree.pptx
PPTX
Binary Heap Tree, Data Structure
PPTX
Doubly Linked List
PDF
Expression trees
Binary Tree in Data Structure
Trees, Binary Search Tree, AVL Tree in Data Structures
Doubly linked list
Tree in data structure
Threaded Binary Tree.pptx
Binary Heap Tree, Data Structure
Doubly Linked List
Expression trees

What's hot (20)

PPT
Linked list
PPT
BINARY TREE REPRESENTATION.ppt
PPT
Binary search tree in data structures
PPTX
Binary Search Tree in Data Structure
PPTX
Binary Search Tree
PPT
1.5 binary search tree
PPTX
PPTX
linked list in data structure
PPTX
AVL Tree Data Structure
PPTX
B and B+ tree
PPT
Databases: Normalisation
PPT
Lecture 1 data structures and algorithms
PPT
1.1 binary tree
PPTX
Red black trees
PPTX
PDF
sparse matrix in data structure
PPTX
Stacks IN DATA STRUCTURES
PPTX
Terminology of tree
PPTX
Linked list
Linked list
BINARY TREE REPRESENTATION.ppt
Binary search tree in data structures
Binary Search Tree in Data Structure
Binary Search Tree
1.5 binary search tree
linked list in data structure
AVL Tree Data Structure
B and B+ tree
Databases: Normalisation
Lecture 1 data structures and algorithms
1.1 binary tree
Red black trees
sparse matrix in data structure
Stacks IN DATA STRUCTURES
Terminology of tree
Linked list
Ad

Similar to Binary tree and operations (20)

PPT
Data Structure And Algorithms for Computer Science
PPTX
Data Structures
PPTX
Binary tree
PPTX
PPTX
NON-LINEAR DATA STRUCTURE-TREES.pptx
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
PPTX
Tree structure and its definitions with an example
PPTX
Saikat techhnology of techtechhnology of techGhorai.pptx
PPT
9. TREE Data Structure Non Linear Data Structure
PDF
Lecture notes data structures tree
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
PPTX
Binary tree operations in data structures
PPTX
Binary tree
PPT
PPTX
Binary Search Tree.pptx
PPTX
Binary tree
PPTX
UNIT 2 TREES & GRAPH COMPLETE NOTES OF DATA STRUCTURE
PPTX
Why Tree is considered a non-linear data structure?
DOCX
Trees in data structrures
PPSX
data structure(tree operations)
Data Structure And Algorithms for Computer Science
Data Structures
Binary tree
NON-LINEAR DATA STRUCTURE-TREES.pptx
UNIT III Non Linear Data Structures - Trees.pptx
Tree structure and its definitions with an example
Saikat techhnology of techtechhnology of techGhorai.pptx
9. TREE Data Structure Non Linear Data Structure
Lecture notes data structures tree
UNIT III Non Linear Data Structures - Trees.pptx
Binary tree operations in data structures
Binary tree
Binary Search Tree.pptx
Binary tree
UNIT 2 TREES & GRAPH COMPLETE NOTES OF DATA STRUCTURE
Why Tree is considered a non-linear data structure?
Trees in data structrures
data structure(tree operations)
Ad

Recently uploaded (20)

PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
master seminar digital applications in india
PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PDF
Basic Mud Logging Guide for educational purpose
PDF
Pre independence Education in Inndia.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Business Ethics Teaching Materials for college
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
human mycosis Human fungal infections are called human mycosis..pptx
master seminar digital applications in india
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
Basic Mud Logging Guide for educational purpose
Pre independence Education in Inndia.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Week 4 Term 3 Study Techniques revisited.pptx
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Business Ethics Teaching Materials for college
Pharmacology of Heart Failure /Pharmacotherapy of CHF
VCE English Exam - Section C Student Revision Booklet
Supply Chain Operations Speaking Notes -ICLT Program
O7-L3 Supply Chain Operations - ICLT Program
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
102 student loan defaulters named and shamed – Is someone you know on the list?
Renaissance Architecture: A Journey from Faith to Humanism
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
Pharma ospi slides which help in ospi learning
STATICS OF THE RIGID BODIES Hibbelers.pdf

Binary tree and operations

  • 3. root node is desigated wich has no parent if the imediate predecessor of the node is parent of the node then all imediate sucessor of a node are known as child child which is on left side is called left child and hat on right side is called right child Basic terminolgies
  • 5. BINARY TREES WITH EXAMPLES
  • 7.  the maximum no of nodes possible in a binary tree of height h is 2power of h-1 The minimum no of nodes possible in a binary tree Height h is h a binary tree has the minimum no of nodes one every parent has one child such kind of trees are called skew binary trees
  • 9. • The root N of T is stored in TREE [1]. If a node occupies TREE [k] then its is stored in TREE and its is stored into TREE
  • 10. Advantage of sequential rpresentation any node can acessed from any other node by calculating the index value data are stored without any pointers to their which are mentioned implicity programing lanuage where dynamic memmory allocation is not possible such as(BASIC ,FORTRAIN)ARRAY REPREPRESENTAION IS nly means to store a tree
  • 11. Disadvantage of sequential reprentation other then the full of binary trees the majority of the array entries may be empty it allows only static representation it is in no way possible to enhance the tree structure if the array size will be limited insering new node to the tree or deleting a node in a tree data moved up and moved down in an array excessive amount of processing time
  • 12. linked list representation of a binary tree they are two field s to stor the address of left child and right child of the node data is the current information of the node if one knows the address of the root node then form it other node can be acessed
  • 13. physical implementation of a binary tree in memmory Algorithm build a tree input:ITEM is the data contet of the node i output: a binary tree with two sub-trees of the node i data structure: array representation of a binary tree
  • 14. operations of binary trees  insertion: TO include a node into an existing binary tree deletion: TO delete a node from a non-empty binary tree Traversal: TO visit all the nodes in abinary tree in traversal they are three orders inorder -> LEFT->ROOT->RIGHT preorder -> ROOT->LEFT->RIGHT postorder-> LEFT->RIGHT->ROOT merge:TO merge two binary trees into a large one
  • 15. in this operation to insert a new node at any position in a binary tree we have a simple insertion for ex to insert a “g “ a new node two stops search the existence node second establish the link
  • 17. insert a binary tree using linked list • insert:KEY is the data content of the key node after new node is to be inserted an ITEM is the data content of the new node can be inserted • output: A node with data component ITEM inserted as an extrernal node after the node having data KEY if such a node does not exist with empty (s), that is, eiter child or both children IS/ARE ABSENT. • DATA STRUCTURE: linked structure of a binary tree. ROOT is the pointer to the root node.
  • 19. algorithm • PRINT “ insertion is not possible as left child” • EXIT • EDIF • ELSE • IF(pf->RC =NULL) • new=GETNODE • new->DATA=ITEM • new->LC=new->RC=NULL • ptr->RC=new • else • print”insertion is not possibble as right child” • exit • end if • else • print”the key node is already has a child” • stop
  • 20. deletion • in deletion operation can be carried out of two kinds of storage representation of binary trees • in ordernto delete a node in a binary tree it is required to reach at the parent node to be deleted • the link of the parent nodes whih stores the location of the node to be deleted is then set buy a NULL entry • input:given ITEM as data of the node with which the node can be identified for deletion • output:a binary tree without a node having a data ITEM • data stucture: array a storing binary trees SIZE denotes the size of a
  • 22. WHAT IS A TRAVERSAL? THE traversal operation is frequently used operation of a binary this operation to visit each node in the tree exactly once a full traversal of a binary tree gives a linear ordering of the data in the tree if a binary tree contains an arithmetic expression then it traverse infix notations,posfix notations,prefix notations
  • 27. input:two pointers ROOT1 and ROOT2 OF THE TWO BINARY TREES t1,t2 output:a binary treee containing all the node t1,t2 ptr to the root as ROOT data structure:linked the data strucure steps: if(ROOT1=NULL)THEN ROOT=ROOT2 EXIT