SlideShare a Scribd company logo
BINARY TREE
1
A SEMINAR ON BY=Mubeen Momin Abdul
Qadeer (co-3g)
Roll no = 5
Binary Trees
• According to the definition of trees, a node can
have any number of children.
• A binary tree is restricted to only having 0, 1, or 2
children.
• A complete binary tree is one where all the levels
are full with exception to the last level and it is
filled from left to right.
• A full binary tree is one where if a node has a
child, then it has two children.
BINARY TREES
Every node in a binary tree can
have at most two children.
The two children of each node are
called the left child and right child
corresponding to their positions.
A node can have only a left child or
only a right child or it can have no
children at all.
Left child is always less that its
parent, while right child is greater
than its parent.
TERMINOLOGY
Each node has to be reachable from the
roots through a unique sequence of arcs
called a path.
The number of arcs in a path is called the
length of the path.
The level of a node is the length of the
path from the root to the node plus 1.
The height of a non-empty tree is the
maximum level of a node in the tree.
Picture of a binary tree5
a
b c
d e
g h i
l
f
j k
The root is
drawn at the top
Tree traversals
 A binary tree is defined recursively: it consists of a root, a
left subtree, and a right subtree
 To traverse (or walk) the binary tree is to visit each node
in the binary tree exactly once
 Tree traversals are naturally recursive
 Since a binary tree has three “parts,” there are six
possible ways to traverse the binary tree:
 root, left, right
 left, root, right
 left, right, root
 root, right, left
 right, root, left
 right, left, root
6
Tree Traversals using
“flags”
• The order in which the nodes are visited during a tree
traversal can be easily determined by imagining there is a
“flag” attached to each node, as follows
• To traverse the tree, collect the flags
7
preorder inorder postorder
A
B C
D E F G
A
B C
D E F G
A
B C
D E F G
A B D E C F G D B E A F C G D E B F G C A
SORTED BINARY
TREES
A binary tree is sorted if every node in the tree is larger
than (or equal to) its left descendants, and smaller than
(or equal to) its right descendants
Equal nodes can go either on the left or the right (but it
has to be consistent)
8
10
8 15
4 12 20
17

More Related Content

PPT
data_structures_and_applications_-_module-4.ppt
PPT
PPTX
Tree all information about tree concept are available .
PPTX
TreesTreesTreesTreesTreesTreesTrees.pptx
PPTX
Lecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptx
PPT
Lecture 5 tree.pptx
PPT
Binary tree traversal ppt - 02.03.2020
PPTX
binary tree.pptx
data_structures_and_applications_-_module-4.ppt
Tree all information about tree concept are available .
TreesTreesTreesTreesTreesTreesTrees.pptx
Lecture-7-Binary-Trees-and-Algorithms-11052023-054009pm.pptx
Lecture 5 tree.pptx
Binary tree traversal ppt - 02.03.2020
binary tree.pptx

Similar to BINARY TREE (20)

PPTX
Data Structures using Python(generic elective).pptx
PPTX
Unit 6 tree
PPTX
DS-UNIT-4zjufrusefihfacbciauhfbaiuhc.pptx
PPT
Lecture 5 trees
PPT
tree.ppt
PPTX
non linear data structure -introduction of tree
PPTX
Data structure using c module 2
PPTX
tree Data Structures in python Traversals.pptx
PPTX
PPTX
Unit-VStackStackStackStackStackStack.pptx
PPT
Unit 3 Tree chapter 5
PPTX
Unit – vi tree
PPT
Chapter 8 ds
PPT
358 33 powerpoint-slides_10-trees_chapter-10
PPTX
Introduction to Tree_Data Structure.pptx
PPTX
discrete mathematics binary%20trees.pptx
PPTX
NON-LINEAR DATA STRUCTURE-TREES.pptx
PPTX
Unit 3 trees
PPTX
tree-160731205832.pptx
PPTX
Tree.pptx
Data Structures using Python(generic elective).pptx
Unit 6 tree
DS-UNIT-4zjufrusefihfacbciauhfbaiuhc.pptx
Lecture 5 trees
tree.ppt
non linear data structure -introduction of tree
Data structure using c module 2
tree Data Structures in python Traversals.pptx
Unit-VStackStackStackStackStackStack.pptx
Unit 3 Tree chapter 5
Unit – vi tree
Chapter 8 ds
358 33 powerpoint-slides_10-trees_chapter-10
Introduction to Tree_Data Structure.pptx
discrete mathematics binary%20trees.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
Unit 3 trees
tree-160731205832.pptx
Tree.pptx
Ad

More from mubeenm50 (7)

PPT
Hacking version 2
PPTX
Listening skills
PPTX
(CGI) Computer generated imagery ppt by Mubeen Momin
PPTX
Hacking
PPTX
Virtual reality with head movement tracking by mubeen momin
PPT
Jini java protocol ppt by Mubeen
PPTX
Wi fi ppt project by Mubeen Momin
Hacking version 2
Listening skills
(CGI) Computer generated imagery ppt by Mubeen Momin
Hacking
Virtual reality with head movement tracking by mubeen momin
Jini java protocol ppt by Mubeen
Wi fi ppt project by Mubeen Momin
Ad

Recently uploaded (20)

PPTX
Microbial diseases, their pathogenesis and prophylaxis
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PPTX
Presentation on HIE in infants and its manifestations
PDF
Classroom Observation Tools for Teachers
PPTX
Cell Types and Its function , kingdom of life
PDF
Complications of Minimal Access Surgery at WLH
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Computing-Curriculum for Schools in Ghana
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
master seminar digital applications in india
PPTX
Institutional Correction lecture only . . .
PDF
RMMM.pdf make it easy to upload and study
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Microbial diseases, their pathogenesis and prophylaxis
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Presentation on HIE in infants and its manifestations
Classroom Observation Tools for Teachers
Cell Types and Its function , kingdom of life
Complications of Minimal Access Surgery at WLH
VCE English Exam - Section C Student Revision Booklet
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Abdominal Access Techniques with Prof. Dr. R K Mishra
FourierSeries-QuestionsWithAnswers(Part-A).pdf
human mycosis Human fungal infections are called human mycosis..pptx
Final Presentation General Medicine 03-08-2024.pptx
A systematic review of self-coping strategies used by university students to ...
Computing-Curriculum for Schools in Ghana
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
master seminar digital applications in india
Institutional Correction lecture only . . .
RMMM.pdf make it easy to upload and study
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx

BINARY TREE

  • 1. BINARY TREE 1 A SEMINAR ON BY=Mubeen Momin Abdul Qadeer (co-3g) Roll no = 5
  • 2. Binary Trees • According to the definition of trees, a node can have any number of children. • A binary tree is restricted to only having 0, 1, or 2 children. • A complete binary tree is one where all the levels are full with exception to the last level and it is filled from left to right. • A full binary tree is one where if a node has a child, then it has two children.
  • 3. BINARY TREES Every node in a binary tree can have at most two children. The two children of each node are called the left child and right child corresponding to their positions. A node can have only a left child or only a right child or it can have no children at all. Left child is always less that its parent, while right child is greater than its parent.
  • 4. TERMINOLOGY Each node has to be reachable from the roots through a unique sequence of arcs called a path. The number of arcs in a path is called the length of the path. The level of a node is the length of the path from the root to the node plus 1. The height of a non-empty tree is the maximum level of a node in the tree.
  • 5. Picture of a binary tree5 a b c d e g h i l f j k The root is drawn at the top
  • 6. Tree traversals  A binary tree is defined recursively: it consists of a root, a left subtree, and a right subtree  To traverse (or walk) the binary tree is to visit each node in the binary tree exactly once  Tree traversals are naturally recursive  Since a binary tree has three “parts,” there are six possible ways to traverse the binary tree:  root, left, right  left, root, right  left, right, root  root, right, left  right, root, left  right, left, root 6
  • 7. Tree Traversals using “flags” • The order in which the nodes are visited during a tree traversal can be easily determined by imagining there is a “flag” attached to each node, as follows • To traverse the tree, collect the flags 7 preorder inorder postorder A B C D E F G A B C D E F G A B C D E F G A B D E C F G D B E A F C G D E B F G C A
  • 8. SORTED BINARY TREES A binary tree is sorted if every node in the tree is larger than (or equal to) its left descendants, and smaller than (or equal to) its right descendants Equal nodes can go either on the left or the right (but it has to be consistent) 8 10 8 15 4 12 20 17