BINARY TREE
AND ITS
OPERATIONS
Team
Hawks
TEAM Hawks
Muhammad Asfer Mahmood
Abdullah Shahid
Muhammad Zain
Hassan
TEAM Hawks
Muhammad Asfer Mahmood
Abdullah Shahid
Muhammad Zain
Hassan
Team Hawks
Muhammad Asfer Mahmood
Abdullah Shahid
Muhammad Zain
Hassan
Team Hawks
Muhammad Asfer Mahmood
Abdullah Shahid
Muhammad Zain
Hassan
Team Hawks
Muhammad Asfer Mahmood
Abdullah Shahid
Muhammad Zain
Hassan
BINARY TREE
AND ITS
OPERATIONS
Defination:
 A binary tree is a hierarchical
data structure,
 in which each node can have
at most two children: a left
child and a right child.
 It is called "binary" because
each node can have at most
two descendants .
9
10
Node: A basic unit of a
binary tree, containing data
and references to its
children.
Parent: A node that
has one or more
child nodes.
Root: The topmost node
of the tree, from which
all other nodes originate.
Leaf: A node with no
children (it is at the
bottom of the tree).
11
Child: A node that is
a descendant of
another node.
Sibling: Nodes
that share the
same parent.
12
Types
Full Binary Tree
each parent node
either has no
children or exactly
two children.
1
/ 
2 3
/  / 
4 5 6 7
Perfect Binary Tree
every non-leaf node
has exactly two
children
1
/ 
2 3
/  / 
4 5 6 7
Complete Binary
Tree almost like a
perfect binary tree
but the last level
might not be
completely filled
1
/ 
2 3
/  /
4 5 6
Balanced Binary
Tree The height
difference between
left and right
subtrees is at most
1.
1
/ 
2 3
/ /
4 5
Traversals
13
In binary tree traversal,
the goal is to visit all the
nodes in a specific order.
Traversals
⊷ Pre-order Traversal
(Root, Left, Right)
⊷ In-order Traversal
(Left, Root, Right)
⊷ Post-order Traversal
(Left, Right, Root)
14
In binary tree traversal,
the goal is to visit all the
nodes in a specific order.
Traversals
15
In binary tree traversal,
the goal is to visit all the
nodes in a specific order.
Root-Left-Right
Root
Traversals
16
In binary tree traversal,
the goal is to visit all the
nodes in a specific order.
Left-Root-Right
Root
Traversals
17
In binary tree traversal,
the goal is to visit all the
nodes in a specific order.
Left-Right-Root
Root
Binary Tree
Traversals
Pre-Order
R->l->r
1, 2, 4, 5, 3
In-Order
l->R->r
4, 2, 5, 1, 3
Post-Order
l->r->R
4, 5, 2, 3, 1
18
1
2 3
5
4
Pre-order
traversal is a
method
where we
visit the root
first, then the
left subtree,
and finally
the right
subtree
19
Binary Tree
Traversals
Pre-order
traversal:
⊷ Used in
file
explorers
because of
hierarchy
⊷* + 4 5
6
((4 + 5) * 6)
Post-order
traversal is
a method
where we
visit the left
subtree first,
then the
right
subtree, and
finally the
root.
In-order
traversal is
a method
where we
visit the left
subtree,
then the
root, and
then the
right
subtree.
20
Binary Tree
Traversals
Post-order
traversal:
⊷ Ensures
dependenci
es
⊷4 5 + 6 *
In-order
traversal:
⊷indexing
systems
⊷4 + 5 *
6
21
Binary Tree
Traversals
((4 + 5) * 6)
Operations:
22
D
e
l
e
t
i
o
n
Insertio
n
S
e
a
r
c
h
Operations:
D
e
l
e
t
i
o
n
Insertio
n
S
e
a
r
c
h
Insertion:
• Start at the root.
• Traverse the tree to find the first available position
• Insert the node at that position.
1
2 3
5
4
6
Insertion:
• Start at the root.
• Traverse the tree to find the first available position
• Insert the node at that position.
1
2 3
5
4
6
Insertion:
• Start at the root.
• Traverse the tree to find the first available position
• Insert the node at that position.
1
2 3
5
4
6
Deletion:
• Node is a leaf: Simply remove the node
• Node has one child: Replace the node with its child.
• Node has two children: Replace the node with the
in-order successor or in-order predecessor.
1
2 3
5
4
2
1
2 3
5
4
2
Deletion:
• Node is a leaf: Simply remove the node
• Node has one child: Replace the node with its child.
• Node has two children: Replace the node with the
in-order successor or in-order predecessor.
1
3
5
4
2
Deletion:
• Node is a leaf: Simply remove the node
• Node has one child: Replace the node with its child.
• Node has two children: Replace the node with the
in-order successor or in-order predecessor.
1
3
5
4
2
Deletion:
• Node is a leaf: Simply remove the node
• Node has one child: Replace the node with its child.
• Node has two children: Replace the node with the
in-order successor or in-order predecessor.
1
3
5
4
Search:
• Start at the root.
• Compare the value with the current node:
If equal, the node is found.
If less, search the left subtree.
If greater, search the right subtree.
3
Applications and Conclusion
32
⊷ Hierarchical Data
Representation:
• Binary trees are used to
represent hierarchical
structures like file
systems, organizational
charts, and decision trees.
33
⊷ Binary Search Trees
(BSTs):
• Efficient searching,
insertion, and deletion of
data.
• Example: Databases and
dictionaries
34
⊷ Expression Trees:
• Binary trees represent
algebraic expressions,
where operators are
internal nodes and
operands are leaves.
• Example: Compilers use
expression trees to
evaluate mathematical
expressions.
35
⊷ Routing and Networking:
• Used in network routing
algorithms like multicast
protocols to decide the
shortest path or
connectivity.
• Example:
• Routers use decision trees
to find the best route for
data packets.
36

More Related Content

PPTX
Tree structure and its definitions with an example
PPTX
trees in data structure
PPTX
Why Tree is considered a non-linear data structure?
PPTX
Unit-VStackStackStackStackStackStack.pptx
PPTX
Introduction to Tree_Data Structure.pptx
PPTX
Data Structures using Python(generic elective).pptx
PPTX
Tree Data Structure & methods & operations
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
Tree structure and its definitions with an example
trees in data structure
Why Tree is considered a non-linear data structure?
Unit-VStackStackStackStackStackStack.pptx
Introduction to Tree_Data Structure.pptx
Data Structures using Python(generic elective).pptx
Tree Data Structure & methods & operations
UNIT III Non Linear Data Structures - Trees.pptx

Similar to Team-hawks_DSA_binary_tree[1] [Read-Only].pptx (20)

PPTX
Saikat techhnology of techtechhnology of techGhorai.pptx
PPTX
binary tree.pptx
PPTX
Binary tree
PPTX
tree Data Structures in python Traversals.pptx
PPTX
Basics of Binary Tree and Binary Search Tree.pptx
PPT
Tree and Binary Search tree
PPTX
Tree
PPTX
learn tree, linked list, queue, stack, and other algo
PDF
Trees, Binary Search Tree, AVL Tree in Data Structures
PPTX
BASIC TREE AND TYPES OF DI CONCEPTS.pptx
PPT
Data Structure And Algorithms for Computer Science
PPTX
PPTX
Data Structure in Tree form. .pptx
PPTX
lecture 17,18. .pptx
PPTX
lecture 17,18. .pptx
PPTX
Unit 6 tree
PPTX
BST.pptx this is Good for data structure
PPTX
BST.pptx this isp used for learning binary search trees
PDF
Chapter 5_Trees.pdf
PPTX
Unit 3 trees
Saikat techhnology of techtechhnology of techGhorai.pptx
binary tree.pptx
Binary tree
tree Data Structures in python Traversals.pptx
Basics of Binary Tree and Binary Search Tree.pptx
Tree and Binary Search tree
Tree
learn tree, linked list, queue, stack, and other algo
Trees, Binary Search Tree, AVL Tree in Data Structures
BASIC TREE AND TYPES OF DI CONCEPTS.pptx
Data Structure And Algorithms for Computer Science
Data Structure in Tree form. .pptx
lecture 17,18. .pptx
lecture 17,18. .pptx
Unit 6 tree
BST.pptx this is Good for data structure
BST.pptx this isp used for learning binary search trees
Chapter 5_Trees.pdf
Unit 3 trees
Ad

More from XEON14 (8)

PPT
Tree.ppt......................................
PPTX
Hashing.pptx......................................
PPTX
Diagnosis with Medical Imaging by Slidesgo [Autosaved].pptx
PPTX
Role of XR in biomedical engineering by Ahmer Ali.pptx
PPTX
lung cancer (1).pptx,...........................
PPTX
Lecture_3.1 Registers.pptx....................
DOCX
Bsf23006565 dsa 3rd assignment.docx............
DOCX
Sample Lab Manual Word Edited aaaaaaaaaaaaaaa
Tree.ppt......................................
Hashing.pptx......................................
Diagnosis with Medical Imaging by Slidesgo [Autosaved].pptx
Role of XR in biomedical engineering by Ahmer Ali.pptx
lung cancer (1).pptx,...........................
Lecture_3.1 Registers.pptx....................
Bsf23006565 dsa 3rd assignment.docx............
Sample Lab Manual Word Edited aaaaaaaaaaaaaaa
Ad

Recently uploaded (20)

PDF
GENERATOR AND IMPROVED COIL THEREFOR HAVINGELECTRODYNAMIC PROPERTIES
PPT
System Unit Components and its Functions
PPTX
New professional education PROF-ED-7_103359.pptx
PDF
Dozuki_Solution-hardware minimalization.
PDF
ICT grade for 8. MATATAG curriculum .P2.pdf
PDF
CAB UNIT 1 with computer details details
PPTX
RTS MASTER DECK_Household Convergence Scorecards. Use this file copy.pptx
PDF
20A LG INR18650HJ2 3.6V 2900mAh Battery cells for Power Tools Vacuum Cleaner
PDF
2- Physical Layer (06).pdfgshshshbsbshshshhs
PPTX
AI_ML_Internship_WReport_Template_v2.pptx
PPTX
Unit-1.pptxgeyeuueueu7r7r7r77r7r7r7uriruru
DOCX
Copy-OT LIST 12.8.25.docxjdjfufufufufuuffuf
PPTX
Growth Capital Investment - Espresso Capital.pptx
PDF
SAHIL PROdhdjejss yo yo pdf TOCOL PPT.pdf
PDF
2_STM32&SecureElements2_STM32&SecureElements
PDF
Printing Presentation to show beginners.
PPTX
Clauses_Part1.hshshpjzjxnznxnxnndndndndndndndnndptx
PPTX
vortex flow measurement in instrumentation
PPTX
ELETRONIC-PRODUCTS-ASSEMBLY-AND-SERVICING-NC-II-WEEK-1-Copy.pptx
PPTX
unit1d-communitypharmacy-240815170017-d032dce8.pptx
GENERATOR AND IMPROVED COIL THEREFOR HAVINGELECTRODYNAMIC PROPERTIES
System Unit Components and its Functions
New professional education PROF-ED-7_103359.pptx
Dozuki_Solution-hardware minimalization.
ICT grade for 8. MATATAG curriculum .P2.pdf
CAB UNIT 1 with computer details details
RTS MASTER DECK_Household Convergence Scorecards. Use this file copy.pptx
20A LG INR18650HJ2 3.6V 2900mAh Battery cells for Power Tools Vacuum Cleaner
2- Physical Layer (06).pdfgshshshbsbshshshhs
AI_ML_Internship_WReport_Template_v2.pptx
Unit-1.pptxgeyeuueueu7r7r7r77r7r7r7uriruru
Copy-OT LIST 12.8.25.docxjdjfufufufufuuffuf
Growth Capital Investment - Espresso Capital.pptx
SAHIL PROdhdjejss yo yo pdf TOCOL PPT.pdf
2_STM32&SecureElements2_STM32&SecureElements
Printing Presentation to show beginners.
Clauses_Part1.hshshpjzjxnznxnxnndndndndndndndnndptx
vortex flow measurement in instrumentation
ELETRONIC-PRODUCTS-ASSEMBLY-AND-SERVICING-NC-II-WEEK-1-Copy.pptx
unit1d-communitypharmacy-240815170017-d032dce8.pptx

Team-hawks_DSA_binary_tree[1] [Read-Only].pptx