SlideShare a Scribd company logo
*
What Is Binary Tree?
*A binary tree is made of nodes, where each node
contains a "left" pointer, a "right" pointer, and a
data element. The "root" pointer points to the
topmost node in the tree. The left and right
pointers recursively point to smaller "sub-trees" on
either side. A null pointer represents a binary tree
with no elements -- the empty tree. The formal
recursive definition is: a binary tree is either empty
(represented by a null pointer), or is made of a
single node, where the left and right pointers
(recursive definition ahead) each point to a binary
tree.
*Parts Of Binary Tree
A
B C
FD GE
H I
Root node &
parent node
Children Node &
successor of
Node A
Sub
tre
e
A is the ancestor of B &
C
Edge
These are
Terminal node
*Complete Binary Tree
*A complete binary tree is a binary tree in which every
level, except possibly the last, is completely filled, and
all nodes are as far left as possible
*Extended Binary Tree
*A binary tree in which special nodes are added
wherever a null subtree was present in the
original tree so that each node in the original
tree (except the root node)
*Traversing Binary Tree
*Often we wish to process a binary tree by "visiting"
each of its nodes, each time performing a specific
action such as printing the contents of the node.
Any process for visiting all of the nodes in some
order is called a Traversal.
*Preorder traversal
* we might wish to make sure
that we visit any given
node before we visit its
children. This is called
a Preorder traversal.
*Preorder traversal
Result:A B D C E G F H I.
*In order Traversal
*An In order Traversal first visits the left
child (including its entire subtree), then
visits the node, and finally visits the right
child (including its entire subtree).
The binary search trees makes use of this
traversal to print all nodes in ascending
order of value.
Inorder result:
B D A G E C H F I.
*Post-Order Traversal
*we might wish to visit each node only after we visit its
children (and their subtrees). For example, this would
be necessary if we wish to return all nodes in the tree
to free store. We would like to delete the children of a
node before deleting the node itself. But to do that
requires that the children's children be deleted first,
and so on. This is called a postorder Traversal.
*Post order resullt:D B G E H I F C A.
*Depth Of Node
*The depth of a node is the number of edges from the
root to the node. The height of a node is the number of
edges from the node to the deepest leaf. The height of
a tree is a height of the root. A full binary tree.is a
binary tree in which each node has exactly zero or two
children.
*Degree Of Tree
*The number of subtrees of a node is called
the degree of the node. In a binary tree,
all nodes have degree 0, 1, or 2.
A node of degree zero is called a terminal node or
leaf node. A non-leaf node is often called a
branch node.
*For this tree the degree of “A” is 2.
*Height Of Tree
*The height of a node is the number of edges on
the longest path from the node to a leaf.
*Here the Height of the tree is
3(H).
A
CB
GD E F
H
*Binary Search Tree
*A binary search tree (BST) is a binary
tree where each node has a Comparable
key (and an associated value) and satisfies
the restriction that the key in any node is
larger than the keys in all nodes in that
node's left subtree and smaller than the
keys in all nodes in that node's right
subtree.
*Heap
*A binary heap is a complete binary tree
which satisfies the heap ordering property.
The ordering can be one of two.
1.Max heap
2.Min heap
*Max Heap
*A max-heap is a complete binary tree in which the value in each
internal node is greater than or equal to the values in the
children of that node.
*Min Heap
*the value of each node is greater than or equal
to the value of its parent, with the minimum-
value element at the root.

More Related Content

What's hot

Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
Zaid Shabbir
 
Binary tree
Binary tree Binary tree
Binary tree
Rajendran
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
Kousalya M
 
Trees
TreesTrees
Binary search tree in data structures
Binary search tree in  data structuresBinary search tree in  data structures
Binary search tree in data structures
chauhankapil
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
Kamran Zafar
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
varagilavanya
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
Abhishek L.R
 
Binary tree
Binary treeBinary tree
Binary tree
Rajendran
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
ManishPrajapati78
 
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2
smruti sarangi
 
Binary Search Tree (BST)
Binary Search Tree (BST)Binary Search Tree (BST)
Binary Search Tree (BST)
M Sajid R
 
Tree-In Data Structure
Tree-In Data StructureTree-In Data Structure
Tree-In Data Structure
United International University
 
Expression trees
Expression treesExpression trees
Expression trees
Salman Vadsarya
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
Adam Mukharil Bachtiar
 
Binary Tree in Data Structure
Binary Tree in Data StructureBinary Tree in Data Structure
Binary Tree in Data Structure
Meghaj Mallick
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
Masud Parvaze
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
SIVAKUMARM603675
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
almario1988
 

What's hot (20)

Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
Binary tree
Binary tree Binary tree
Binary tree
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Trees
TreesTrees
Trees
 
Binary search tree in data structures
Binary search tree in  data structuresBinary search tree in  data structures
Binary search tree in data structures
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Binary tree
Binary treeBinary tree
Binary tree
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 
Data Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search TreeData Structure and Algorithms Binary Search Tree
Data Structure and Algorithms Binary Search Tree
 
Data structure using c module 2
Data structure using c module 2Data structure using c module 2
Data structure using c module 2
 
Binary Search Tree (BST)
Binary Search Tree (BST)Binary Search Tree (BST)
Binary Search Tree (BST)
 
Tree-In Data Structure
Tree-In Data StructureTree-In Data Structure
Tree-In Data Structure
 
Expression trees
Expression treesExpression trees
Expression trees
 
Data Structure (Tree)
Data Structure (Tree)Data Structure (Tree)
Data Structure (Tree)
 
Binary Tree in Data Structure
Binary Tree in Data StructureBinary Tree in Data Structure
Binary Tree in Data Structure
 
Discrete Mathematics Tree
Discrete Mathematics  TreeDiscrete Mathematics  Tree
Discrete Mathematics Tree
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
 

Viewers also liked

Ch13 Binary Search Tree
Ch13 Binary Search TreeCh13 Binary Search Tree
Ch13 Binary Search Treeleminhvuong
 
Altar de Muertos
Altar de Muertos Altar de Muertos
Altar de Muertos
Erika Said
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
Gurukul Kangri Vishwavidyalaya - Faculty of Engineering and Technology
 
Trees
TreesTrees
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
ER Punit Jain
 
Cse Binary tree presentation
Cse Binary tree presentationCse Binary tree presentation
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
GowriKumar Chandramouli
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
Geunhyung Kim
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
Muhazzab Chouhadry
 
Binomial heap presentation
Binomial heap presentationBinomial heap presentation
Binomial heap presentationHafsa.Naseem
 
Data Structures
Data StructuresData Structures
Data Structures
Nitesh Bichwani
 
Trees - Data structures in C/Java
Trees - Data structures in C/JavaTrees - Data structures in C/Java
Trees - Data structures in C/Javageeksrik
 

Viewers also liked (15)

Ch13 Binary Search Tree
Ch13 Binary Search TreeCh13 Binary Search Tree
Ch13 Binary Search Tree
 
Altar de Muertos
Altar de Muertos Altar de Muertos
Altar de Muertos
 
Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures Trees, Binary Search Tree, AVL Tree in Data Structures
Trees, Binary Search Tree, AVL Tree in Data Structures
 
Trees
TreesTrees
Trees
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
 
Binary trees
Binary treesBinary trees
Binary trees
 
Cse Binary tree presentation
Cse Binary tree presentationCse Binary tree presentation
Cse Binary tree presentation
 
binary tree
binary treebinary tree
binary tree
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
6. binary tree
6. binary tree6. binary tree
6. binary tree
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Binomial heap presentation
Binomial heap presentationBinomial heap presentation
Binomial heap presentation
 
Data Structures
Data StructuresData Structures
Data Structures
 
Trees - Data structures in C/Java
Trees - Data structures in C/JavaTrees - Data structures in C/Java
Trees - Data structures in C/Java
 
Binary tree
Binary treeBinary tree
Binary tree
 

Similar to Binary tree and Binary search tree

Dsc++ unit 3 notes
Dsc++ unit 3 notesDsc++ unit 3 notes
Dsc++ unit 3 notes
Guru Nanak Institute Of Tech
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
worldchannel
 
Graph Traversals
Graph TraversalsGraph Traversals
Graph Traversals
MaryJacob24
 
Final tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentationFinal tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentation
nakulvarshney371
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
Abirami A
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
skilljiolms
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
Om Prakash
 
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
 
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
 
binary tree.pptx
binary tree.pptxbinary tree.pptx
binary tree.pptx
DhanushSrinivasulu
 
Trees.pptx
Trees.pptxTrees.pptx
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
sumitbardhan
 
Chapter 5_Trees.pdf
Chapter 5_Trees.pdfChapter 5_Trees.pdf
Chapter 5_Trees.pdf
ssuser50179b
 
tree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptxtree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptx
RupaRaj6
 
Trees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsTrees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and Algorithms
BHARATH KUMAR
 
Trees in data structrures
Trees in data structruresTrees in data structrures
Trees in data structrures
Gaurav Sharma
 
Unit 6 tree
Unit   6 treeUnit   6 tree
Unit 6 tree
Dabbal Singh Mahara
 
Trees
TreesTrees

Similar to Binary tree and Binary search tree (20)

Dsc++ unit 3 notes
Dsc++ unit 3 notesDsc++ unit 3 notes
Dsc++ unit 3 notes
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
Graph Traversals
Graph TraversalsGraph Traversals
Graph Traversals
 
Final tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentationFinal tree.ppt tells about tree presentation
Final tree.ppt tells about tree presentation
 
Lecture 5 tree.pptx
Lecture 5 tree.pptxLecture 5 tree.pptx
Lecture 5 tree.pptx
 
VCE Unit 05.pptx
VCE Unit 05.pptxVCE Unit 05.pptx
VCE Unit 05.pptx
 
Trees in Data Structure
Trees in Data StructureTrees in Data Structure
Trees in Data Structure
 
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
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
 
binary tree.pptx
binary tree.pptxbinary tree.pptx
binary tree.pptx
 
Trees.pptx
Trees.pptxTrees.pptx
Trees.pptx
 
358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10358 33 powerpoint-slides_10-trees_chapter-10
358 33 powerpoint-slides_10-trees_chapter-10
 
Trees
TreesTrees
Trees
 
Chapter 5_Trees.pdf
Chapter 5_Trees.pdfChapter 5_Trees.pdf
Chapter 5_Trees.pdf
 
tree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptxtree Data Structures in python Traversals.pptx
tree Data Structures in python Traversals.pptx
 
Trees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and AlgorithmsTrees and Graphs in data structures and Algorithms
Trees and Graphs in data structures and Algorithms
 
Trees in data structrures
Trees in data structruresTrees in data structrures
Trees in data structrures
 
Unit 6 tree
Unit   6 treeUnit   6 tree
Unit 6 tree
 
Trees
TreesTrees
Trees
 

Recently uploaded

DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
Kamal Acharya
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
Osamah Alsalih
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 

Recently uploaded (20)

DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Cosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdfCosmetic shop management system project report.pdf
Cosmetic shop management system project report.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
MCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdfMCQ Soil mechanics questions (Soil shear strength).pdf
MCQ Soil mechanics questions (Soil shear strength).pdf
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 

Binary tree and Binary search tree

  • 1. *
  • 2. What Is Binary Tree? *A binary tree is made of nodes, where each node contains a "left" pointer, a "right" pointer, and a data element. The "root" pointer points to the topmost node in the tree. The left and right pointers recursively point to smaller "sub-trees" on either side. A null pointer represents a binary tree with no elements -- the empty tree. The formal recursive definition is: a binary tree is either empty (represented by a null pointer), or is made of a single node, where the left and right pointers (recursive definition ahead) each point to a binary tree.
  • 3. *Parts Of Binary Tree A B C FD GE H I Root node & parent node Children Node & successor of Node A Sub tre e A is the ancestor of B & C Edge These are Terminal node
  • 4. *Complete Binary Tree *A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible
  • 5. *Extended Binary Tree *A binary tree in which special nodes are added wherever a null subtree was present in the original tree so that each node in the original tree (except the root node)
  • 6. *Traversing Binary Tree *Often we wish to process a binary tree by "visiting" each of its nodes, each time performing a specific action such as printing the contents of the node. Any process for visiting all of the nodes in some order is called a Traversal.
  • 7. *Preorder traversal * we might wish to make sure that we visit any given node before we visit its children. This is called a Preorder traversal. *Preorder traversal Result:A B D C E G F H I.
  • 8. *In order Traversal *An In order Traversal first visits the left child (including its entire subtree), then visits the node, and finally visits the right child (including its entire subtree). The binary search trees makes use of this traversal to print all nodes in ascending order of value. Inorder result: B D A G E C H F I.
  • 9. *Post-Order Traversal *we might wish to visit each node only after we visit its children (and their subtrees). For example, this would be necessary if we wish to return all nodes in the tree to free store. We would like to delete the children of a node before deleting the node itself. But to do that requires that the children's children be deleted first, and so on. This is called a postorder Traversal. *Post order resullt:D B G E H I F C A.
  • 10. *Depth Of Node *The depth of a node is the number of edges from the root to the node. The height of a node is the number of edges from the node to the deepest leaf. The height of a tree is a height of the root. A full binary tree.is a binary tree in which each node has exactly zero or two children.
  • 11. *Degree Of Tree *The number of subtrees of a node is called the degree of the node. In a binary tree, all nodes have degree 0, 1, or 2. A node of degree zero is called a terminal node or leaf node. A non-leaf node is often called a branch node. *For this tree the degree of “A” is 2.
  • 12. *Height Of Tree *The height of a node is the number of edges on the longest path from the node to a leaf. *Here the Height of the tree is 3(H). A CB GD E F H
  • 13. *Binary Search Tree *A binary search tree (BST) is a binary tree where each node has a Comparable key (and an associated value) and satisfies the restriction that the key in any node is larger than the keys in all nodes in that node's left subtree and smaller than the keys in all nodes in that node's right subtree.
  • 14. *Heap *A binary heap is a complete binary tree which satisfies the heap ordering property. The ordering can be one of two. 1.Max heap 2.Min heap
  • 15. *Max Heap *A max-heap is a complete binary tree in which the value in each internal node is greater than or equal to the values in the children of that node.
  • 16. *Min Heap *the value of each node is greater than or equal to the value of its parent, with the minimum- value element at the root.