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.
Ad

More Related Content

What's hot (20)

Binary search tree in data structures
Binary search tree in  data structuresBinary search tree in  data structures
Binary search tree in data structures
chauhankapil
 
UNIT-4 TREES.ppt
UNIT-4 TREES.pptUNIT-4 TREES.ppt
UNIT-4 TREES.ppt
SIVAKUMARM603675
 
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
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
V.V.Vanniaperumal College for Women
 
Trees (data structure)
Trees (data structure)Trees (data structure)
Trees (data structure)
Trupti Agrawal
 
AVL Tree in Data Structure
AVL Tree in Data Structure AVL Tree in Data Structure
AVL Tree in Data Structure
Vrushali Dhanokar
 
1.1 binary tree
1.1 binary tree1.1 binary tree
1.1 binary tree
Krish_ver2
 
B tree
B treeB tree
B tree
Rajendran
 
Heap tree
Heap treeHeap tree
Heap tree
JananiJ19
 
Binary Search Tree and AVL
Binary Search Tree and AVLBinary Search Tree and AVL
Binary Search Tree and AVL
Katang Isip
 
2 3 Trees Algorithm - Data Structure
2 3 Trees Algorithm - Data Structure2 3 Trees Algorithm - Data Structure
2 3 Trees Algorithm - Data Structure
Tish997
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operations
babuk110
 
1.5 binary search tree
1.5 binary search tree1.5 binary search tree
1.5 binary search tree
Krish_ver2
 
Binary search tree(bst)
Binary search tree(bst)Binary search tree(bst)
Binary search tree(bst)
Hossain Md Shakhawat
 
10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil10. Search Tree - Data Structures using C++ by Varsha Patil
10. Search Tree - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Expression trees
Expression treesExpression trees
Expression trees
Salman Vadsarya
 
Double Linked List (Algorithm)
Double Linked List (Algorithm)Double Linked List (Algorithm)
Double Linked List (Algorithm)
Huba Akhtar
 
Introduction to data structure
Introduction to data structure Introduction to data structure
Introduction to data structure
NUPOORAWSARMOL
 
Binary tree
Binary treeBinary tree
Binary tree
Rajendran
 
01.number systems
01.number systems01.number systems
01.number systems
rasha3
 

Viewers also liked (17)

Ch13 Binary Search Tree
Ch13 Binary Search TreeCh13 Binary Search Tree
Ch13 Binary Search Tree
leminhvuong
 
Altar de Muertos
Altar de Muertos Altar de Muertos
Altar de Muertos
Erika Said
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
almario1988
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
Zaid Shabbir
 
Trees
TreesTrees
Trees
Ankit Sharma
 
BINARY SEARCH TREE
BINARY SEARCH TREEBINARY SEARCH TREE
BINARY SEARCH TREE
ER Punit Jain
 
Binary trees
Binary treesBinary trees
Binary trees
Simratpreet Singh
 
Cse Binary tree presentation
Cse Binary tree presentationCse Binary tree presentation
Cse Binary tree presentation
সৈয়দ সাব্বির রহমান
 
binary tree
binary treebinary tree
binary tree
Shankar Bishnoi
 
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 presentation
Hafsa.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/Java
geeksrik
 
Binary tree
Binary treeBinary tree
Binary tree
Ssankett Negi
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
Sumit Gupta
 
Ad

Similar to Binary tree and Binary search tree (20)

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
 
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
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
JITTAYASHWANTHREDDY
 
data structures Unit 3 notes.docxdata structures Unit 3 notes.docx
data structures Unit 3 notes.docxdata structures Unit 3 notes.docxdata structures Unit 3 notes.docxdata structures Unit 3 notes.docx
data structures Unit 3 notes.docxdata structures Unit 3 notes.docx
yatakonakiran2
 
binary tree.pptx
binary tree.pptxbinary tree.pptx
binary tree.pptx
DhanushSrinivasulu
 
Binary search Tree and avl tree , treee.ppt
Binary search Tree and avl tree , treee.pptBinary search Tree and avl tree , treee.ppt
Binary search Tree and avl tree , treee.ppt
sjain87654321
 
Introduction to Tree_Data Structure.pptx
Introduction to Tree_Data Structure.pptxIntroduction to Tree_Data Structure.pptx
Introduction to Tree_Data Structure.pptx
PoojariniMitra1
 
Trees.pptx
Trees.pptxTrees.pptx
Trees.pptx
REMEGIUSPRAVEENSAHAY
 
Binary Trees.pptx module 122img 787554yau
Binary Trees.pptx module 122img 787554yauBinary Trees.pptx module 122img 787554yau
Binary Trees.pptx module 122img 787554yau
rithusagar5
 
9. TREE Data Structure Non Linear Data Structure
9. TREE Data Structure Non Linear Data Structure9. TREE Data Structure Non Linear Data Structure
9. TREE Data Structure Non Linear Data Structure
kejika1215
 
Data Structure And Algorithms for Computer Science
Data Structure And Algorithms for Computer ScienceData Structure And Algorithms for Computer Science
Data Structure And Algorithms for Computer Science
ManishShukla712917
 
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
 
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
 
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
 
data structures Unit 3 notes.docxdata structures Unit 3 notes.docx
data structures Unit 3 notes.docxdata structures Unit 3 notes.docxdata structures Unit 3 notes.docxdata structures Unit 3 notes.docx
data structures Unit 3 notes.docxdata structures Unit 3 notes.docx
yatakonakiran2
 
Binary search Tree and avl tree , treee.ppt
Binary search Tree and avl tree , treee.pptBinary search Tree and avl tree , treee.ppt
Binary search Tree and avl tree , treee.ppt
sjain87654321
 
Introduction to Tree_Data Structure.pptx
Introduction to Tree_Data Structure.pptxIntroduction to Tree_Data Structure.pptx
Introduction to Tree_Data Structure.pptx
PoojariniMitra1
 
Binary Trees.pptx module 122img 787554yau
Binary Trees.pptx module 122img 787554yauBinary Trees.pptx module 122img 787554yau
Binary Trees.pptx module 122img 787554yau
rithusagar5
 
9. TREE Data Structure Non Linear Data Structure
9. TREE Data Structure Non Linear Data Structure9. TREE Data Structure Non Linear Data Structure
9. TREE Data Structure Non Linear Data Structure
kejika1215
 
Data Structure And Algorithms for Computer Science
Data Structure And Algorithms for Computer ScienceData Structure And Algorithms for Computer Science
Data Structure And Algorithms for Computer Science
ManishShukla712917
 
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
 
Ad

Recently uploaded (20)

Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic AlgorithmDesign Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Design Optimization of Reinforced Concrete Waffle Slab Using Genetic Algorithm
Journal of Soft Computing in Civil Engineering
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
Frontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend EngineersFrontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend Engineers
Michael Hertzberg
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Using the Artificial Neural Network to Predict the Axial Strength and Strain ...
Journal of Soft Computing in Civil Engineering
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 
acid base ppt and their specific application in food
acid base ppt and their specific application in foodacid base ppt and their specific application in food
acid base ppt and their specific application in food
Fatehatun Noor
 
twin tower attack 2001 new york city
twin  tower  attack  2001 new  york citytwin  tower  attack  2001 new  york city
twin tower attack 2001 new york city
harishreemavs
 
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software ApplicationsJacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia - Excels In Optimizing Software Applications
Jacob Murphy Australia
 
Slide share PPT of NOx control technologies.pptx
Slide share PPT of  NOx control technologies.pptxSlide share PPT of  NOx control technologies.pptx
Slide share PPT of NOx control technologies.pptx
vvsasane
 
hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .hypermedia_system_revisit_roy_fielding .
hypermedia_system_revisit_roy_fielding .
NABLAS株式会社
 
Machine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATIONMachine Learning basics POWERPOINT PRESENETATION
Machine Learning basics POWERPOINT PRESENETATION
DarrinBright1
 
Applications of Centroid in Structural Engineering
Applications of Centroid in Structural EngineeringApplications of Centroid in Structural Engineering
Applications of Centroid in Structural Engineering
suvrojyotihalder2006
 
Agents chapter of Artificial intelligence
Agents chapter of Artificial intelligenceAgents chapter of Artificial intelligence
Agents chapter of Artificial intelligence
DebdeepMukherjee9
 
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdfLittle Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
Little Known Ways To 3 Best sites to Buy Linkedin Accounts.pdf
gori42199
 
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
6th International Conference on Big Data, Machine Learning and IoT (BMLI 2025)
ijflsjournal087
 
Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025Transport modelling at SBB, presentation at EPFL in 2025
Transport modelling at SBB, presentation at EPFL in 2025
Antonin Danalet
 
Frontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend EngineersFrontend Architecture Diagram/Guide For Frontend Engineers
Frontend Architecture Diagram/Guide For Frontend Engineers
Michael Hertzberg
 
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdfSmart City is the Future EN - 2024 Thailand Modify V1.0.pdf
Smart City is the Future EN - 2024 Thailand Modify V1.0.pdf
PawachMetharattanara
 
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdfATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ATAL 6 Days Online FDP Scheme Document 2025-26.pdf
ssuserda39791
 
Machine foundation notes for civil engineering students
Machine foundation notes for civil engineering studentsMachine foundation notes for civil engineering students
Machine foundation notes for civil engineering students
DYPCET
 
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdfML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
ML_Unit_VI_DEEP LEARNING_Introduction to ANN.pdf
rameshwarchintamani
 
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
sss1.pptxsss1.pptxsss1.pptxsss1.pptxsss1.pptx
ajayrm685
 
Construction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil EngineeringConstruction Materials (Paints) in Civil Engineering
Construction Materials (Paints) in Civil Engineering
Lavish Kashyap
 

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