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
Ad

More Related Content

What's hot (20)

Threaded Binary Tree.pptx
Threaded Binary Tree.pptxThreaded Binary Tree.pptx
Threaded Binary Tree.pptx
pavankumarjakkepalli
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
Ashim Lamichhane
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
almario1988
 
Queue in Data Structure
Queue in Data Structure Queue in Data Structure
Queue in Data Structure
Janki Shah
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURESStacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
Adam Mukharil Bachtiar
 
linked lists in data structures
linked lists in data structureslinked lists in data structures
linked lists in data structures
DurgaDeviCbit
 
Linked list
Linked listLinked list
Linked list
KalaivaniKS1
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
Afaq Mansoor Khan
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
ghhgj jhgh
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
Hashing
HashingHashing
Hashing
LavanyaJ28
 
Stack
StackStack
Stack
Zaid Shabbir
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
shameen khan
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
khabbab_h
 
Binary tree
Binary  treeBinary  tree
Binary tree
Vanitha Chandru
 
AVL Tree in Data Structure
AVL Tree in Data Structure AVL Tree in Data Structure
AVL Tree in Data Structure
Vrushali Dhanokar
 
b+ tree
b+ treeb+ tree
b+ tree
bitistu
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
Krish_ver2
 
B+ trees and height balance tree
B+ trees and height balance treeB+ trees and height balance tree
B+ trees and height balance tree
Jasleen Kaur (Chandigarh University)
 

Similar to Binary tree and operations (20)

Algorithm and Data Structure - Binary Trees
Algorithm and Data Structure - Binary TreesAlgorithm and Data Structure - Binary Trees
Algorithm and Data Structure - Binary Trees
donotreply20
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
Rajitha Reddy Alugati
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxTREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
asimshahzad8611
 
Trees
TreesTrees
Trees
9590133127
 
UNIT III Non Linear Data Structures - Trees.pptx
UNIT III Non Linear Data Structures - Trees.pptxUNIT III Non Linear Data Structures - Trees.pptx
UNIT III Non Linear Data Structures - Trees.pptx
VISWANATHAN R V
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
Data Structure Lecture 3 Linked Lists.pdf
Data Structure Lecture 3 Linked Lists.pdfData Structure Lecture 3 Linked Lists.pdf
Data Structure Lecture 3 Linked Lists.pdf
donotreply20
 
Tree
TreeTree
Tree
maamir farooq
 
Dsc++ unit 3 notes
Dsc++ unit 3 notesDsc++ unit 3 notes
Dsc++ unit 3 notes
Guru Nanak Institute Of Tech
 
Treeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdf
Treeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdfTreeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdf
Treeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdf
timoemin50
 
UNIT III Non Linear Data Structures - Trees.pptx
UNIT III Non Linear Data Structures - Trees.pptxUNIT III Non Linear Data Structures - Trees.pptx
UNIT III Non Linear Data Structures - Trees.pptx
kncetaruna
 
Unit 4.1 (tree)
Unit 4.1 (tree)Unit 4.1 (tree)
Unit 4.1 (tree)
DurgaDeviCbit
 
Trees in data structrures
Trees in data structruresTrees in data structrures
Trees in data structrures
Gaurav Sharma
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
skilljiolms
 
Unit iv data structure-converted
Unit  iv data structure-convertedUnit  iv data structure-converted
Unit iv data structure-converted
Shri Shankaracharya College, Bhilai,Junwani
 
Tree
TreeTree
Tree
bhumish
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
SeethaDinesh
 
Unit8 C
Unit8 CUnit8 C
Unit8 C
arnold 7490
 
Introduction to Tree_Data Structure.pptx
Introduction to Tree_Data Structure.pptxIntroduction to Tree_Data Structure.pptx
Introduction to Tree_Data Structure.pptx
PoojariniMitra1
 
Data Structures
Data StructuresData Structures
Data Structures
Nitesh Bichwani
 
Algorithm and Data Structure - Binary Trees
Algorithm and Data Structure - Binary TreesAlgorithm and Data Structure - Binary Trees
Algorithm and Data Structure - Binary Trees
donotreply20
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
Rajitha Reddy Alugati
 
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptxTREE DATA STRUCTURE SLIDES dsa dsa .pptx
TREE DATA STRUCTURE SLIDES dsa dsa .pptx
asimshahzad8611
 
UNIT III Non Linear Data Structures - Trees.pptx
UNIT III Non Linear Data Structures - Trees.pptxUNIT III Non Linear Data Structures - Trees.pptx
UNIT III Non Linear Data Structures - Trees.pptx
VISWANATHAN R V
 
Tree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal KhanTree Data Structure by Daniyal Khan
Tree Data Structure by Daniyal Khan
Daniyal Khan
 
Data Structure Lecture 3 Linked Lists.pdf
Data Structure Lecture 3 Linked Lists.pdfData Structure Lecture 3 Linked Lists.pdf
Data Structure Lecture 3 Linked Lists.pdf
donotreply20
 
Treeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdf
Treeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdfTreeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdf
Treeeeeeeeeeeeeeeeereeeeeeeeeeeeeeee.pdf
timoemin50
 
UNIT III Non Linear Data Structures - Trees.pptx
UNIT III Non Linear Data Structures - Trees.pptxUNIT III Non Linear Data Structures - Trees.pptx
UNIT III Non Linear Data Structures - Trees.pptx
kncetaruna
 
Trees in data structrures
Trees in data structruresTrees in data structrures
Trees in data structrures
Gaurav Sharma
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
skilljiolms
 
BINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.pptBINARY TREE REPRESENTATION.ppt
BINARY TREE REPRESENTATION.ppt
SeethaDinesh
 
Introduction to Tree_Data Structure.pptx
Introduction to Tree_Data Structure.pptxIntroduction to Tree_Data Structure.pptx
Introduction to Tree_Data Structure.pptx
PoojariniMitra1
 
Ad

Recently uploaded (20)

How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18How to Share Accounts Between Companies in Odoo 18
How to Share Accounts Between Companies in Odoo 18
Celine George
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and GuestsLDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDMMIA Reiki News Ed3 Vol1 For Team and Guests
LDM Mia eStudios
 
Ancient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian HistoryAncient Stone Sculptures of India: As a Source of Indian History
Ancient Stone Sculptures of India: As a Source of Indian History
Virag Sontakke
 
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living WorkshopLDMMIA Reiki Yoga S5 Daily Living Workshop
LDMMIA Reiki Yoga S5 Daily Living Workshop
LDM Mia eStudios
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...Classification of mental disorder in 5th semester bsc. nursing and also used ...
Classification of mental disorder in 5th semester bsc. nursing and also used ...
parmarjuli1412
 
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
MCQ PHYSIOLOGY II (DR. NASIR MUSTAFA) MCQS)
Dr. Nasir Mustafa
 
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFAMEDICAL BIOLOGY MCQS  BY. DR NASIR MUSTAFA
MEDICAL BIOLOGY MCQS BY. DR NASIR MUSTAFA
Dr. Nasir Mustafa
 
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
How to Clean Your Contacts Using the Deduplication Menu in Odoo 18
Celine George
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Drugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdfDrugs in Anaesthesia and Intensive Care,.pdf
Drugs in Anaesthesia and Intensive Care,.pdf
crewot855
 
Search Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo SlidesSearch Matching Applicants in Odoo 18 - Odoo Slides
Search Matching Applicants in Odoo 18 - Odoo Slides
Celine George
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
Form View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo SlidesForm View Attributes in Odoo 18 - Odoo Slides
Form View Attributes in Odoo 18 - Odoo Slides
Celine George
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
Myopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduateMyopathies (muscle disorders) for undergraduate
Myopathies (muscle disorders) for undergraduate
Mohamed Rizk Khodair
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
BÀI TẬP BỔ TRỢ TIẾNG ANH 9 THEO ĐƠN VỊ BÀI HỌC - GLOBAL SUCCESS - CẢ NĂM (TỪ...
Nguyen Thanh Tu Collection
 
*"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"**"Sensing the World: Insect Sensory Systems"*
*"Sensing the World: Insect Sensory Systems"*
Arshad Shaikh
 
Ad

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
  翻译: