SlideShare a Scribd company logo
Topic 5
TREE
DFC 30233 DATA STRUCTURE
1.0 Define tree,binary tree and binary search tree
BINARY TREE
 A type of data structure where each
parent node can have at most two
child nodes
 These two child nodes are
known as the left
child and right child.
1.0 Define tree,binary tree and binary search tree
BINARY SEARCH TREE
 A binary search tree is a binary tree in which the
nodes are assigned values, with the following
restrictions ;
• No duplicate values
• Left child node is smaller than its parent Node
• Right child node is greater than its parent Node
DID YOU KNOW?
― Irene M. Pepperberg
1.2 Terminology in relation to trees:
1. Root,
2. Parent,
3. Children,
4. Leaves,
5. Sibling,
6. Node,
7. Path,
8. Degree,
9. Level
Root
 ROOT NODE - the first node
 root node is the origin of tree
data structure
 must be only one root node
Terminology: 1. Root
Parent Node
 PARENT NODE - the node
which is predecessor of any node
 the node which has branch from it
to any other node
Terminology: 2. Parent
Child
 Child Node - the node which is
descendant of any node
 the node which has a link from its
parent node
 any parent node can have any
number of child nodes
 all the nodes except root are child
nodes
Terminology: 3. Children
Leaf
 LEAF Node - the node which does
not have a child
 leaf node is also called as
Terminal node
Terminology: 4. Leaf
Siblings
 SIBLINGS - nodes which
belong to same Parent
Terminology: 5. Siblings
Internal Nodes
 INTERNAL Node - the node which has at least one child
 Internal nodes are also called as 'Non-Terminal' nodes
Terminology: 6. Internal Nodes
Path
 PATH - the sequence of
Nodes and Edges from one
node to another node
 Length of a Path is total
number of nodes in that
path.
 Example: the path A - B - E -
J has length 4
Terminology: 7. Path
Degree
 PATH - the sequence of
Nodes and Edges from one
node to another node
 Length of a Path is total
number of nodes in that
path.
 Example: the path A - B - E -
J has length 4
Terminology: 8. Degree
Edge
 EDGE - the connecting
link between any two nodes
 In a tree with 'N' number of
nodes there will be a
maximum of
● 'N-1' number of edges.
Terminology: 9. Edge
Level
 LEVEL - each step from top
to bottom
 the root node - Level 0
 the children of root node -
Level 1
Terminology: 10. Level
Height
 height of all leaf nodes is '0'
Terminology: 11. Height
Depth
 height of all leaf nodes is '0'
Terminology: 12. Depth
Terminology: 13. Sub Tree
notesCHAPTER_5_tree_data_structure_ds.pppt
2.0 Binary Tree.
Binary Tree is a tree in
which every node can have
a maximum of two children.
Every node can have either
0 children or 1 child or 2
children but not more
than 2 children.
Full Binary Tree
Binary Tree
Perfect Binary Tree
Complete Binary Tree
obtained from a perfect binary tree by deleting
consecutive leaves of the tree from right to left
Arithmetic
Expression
Example: arithmetic expression tree for the
expression (2 × (a - 1)) + (3 × b) :
Infix, Prefix and Postfix
traversal
An infix expression, the operator
appears between its operands.
In a prefix expression, places a
binary operator before its
operands.
In a postfix expression, the binary
operators comes after its operands.
notesCHAPTER_5_tree_data_structure_ds.pppt
Example
1
State the order of nodes visited using prefix, infix and postfix
traversal.
Prefix: - 8 / 4 2
Infix: 8 – ( 4 / 2 )
Postfix: 8 4 2 / -
Example
2
State the order of nodes visited using prefix, infix and postfix
traversal.
Infix form:
Prefix form:
Postfix form:
a) (x+xy) + (x/y)
b) x+ ((xy+x)/y)
1. Represent the expressions using binary trees.
2. Write these expressions in prefix notation.
3. Write these expressions in postfix notation.
4. Write these expressions in infix notation.
Binary Tree
Representations
 A binary tree data structure is represented using two methods.
Those methods are as follows.
 Array Representation
 Linked List Representation
 Consider the following binary tree.
1. Array
Representation
2. Linked List Representation
notesCHAPTER_5_tree_data_structure_ds.pppt

More Related Content

PPT
UNIT-4 TREES.ppt
PPT
Final tree.ppt tells about tree presentation
DOCX
data structures Unit 3 notes.docxdata structures Unit 3 notes.docx
PPTX
TREE PRESENTATION COMPUTER SCIENCE/DATA STRUCTURE
PPTX
Data Structures -Non Linear DS-Basics ofTrees
PDF
Dsc++ unit 3 notes
DOCX
Trees and Graphs in data structures and Algorithms
PPTX
Tree structure and its definitions with an example
UNIT-4 TREES.ppt
Final tree.ppt tells about tree presentation
data structures Unit 3 notes.docxdata structures Unit 3 notes.docx
TREE PRESENTATION COMPUTER SCIENCE/DATA STRUCTURE
Data Structures -Non Linear DS-Basics ofTrees
Dsc++ unit 3 notes
Trees and Graphs in data structures and Algorithms
Tree structure and its definitions with an example

Similar to notesCHAPTER_5_tree_data_structure_ds.pppt (20)

PPT
9. TREE Data Structure Non Linear Data Structure
PDF
7 chapter4 trees_binary
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
PPTX
Data Structure of computer science and technology
PPTX
TREES basics simple introduction .pptx
PPTX
TREES 1.pptx
PPTX
Trees in data structures
PPTX
UNIT III Non Linear Data Structures - Trees.pptx
DOCX
Unit 3,4.docx
PPTX
Tree.pptx
PPTX
Tree all information about tree concept are available .
PPTX
trees in data structure
PPTX
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
PDF
AD3251-Data Structures Design-Notes-Tree.pdf
PPTX
Saikat techhnology of techtechhnology of techGhorai.pptx
PPTX
Binary Trees - Tree Terminologies and representation
PPTX
Trees, Basic Terminology and Binary Trees
PPT
Chapter 8 ds
PPTX
Tree Data Structure in Advanced Data Structure
PPTX
Basic Tree Data Structure BST Traversals .pptx
9. TREE Data Structure Non Linear Data Structure
7 chapter4 trees_binary
UNIT III Non Linear Data Structures - Trees.pptx
Data Structure of computer science and technology
TREES basics simple introduction .pptx
TREES 1.pptx
Trees in data structures
UNIT III Non Linear Data Structures - Trees.pptx
Unit 3,4.docx
Tree.pptx
Tree all information about tree concept are available .
trees in data structure
Data Structures Module 3 Binary Trees Binary Search Trees Tree Traversals AVL...
AD3251-Data Structures Design-Notes-Tree.pdf
Saikat techhnology of techtechhnology of techGhorai.pptx
Binary Trees - Tree Terminologies and representation
Trees, Basic Terminology and Binary Trees
Chapter 8 ds
Tree Data Structure in Advanced Data Structure
Basic Tree Data Structure BST Traversals .pptx
Ad

Recently uploaded (20)

PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Complications of Minimal Access Surgery at WLH
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
01-Introduction-to-Information-Management.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Cell Structure & Organelles in detailed.
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Computing-Curriculum for Schools in Ghana
Anesthesia in Laparoscopic Surgery in India
human mycosis Human fungal infections are called human mycosis..pptx
Supply Chain Operations Speaking Notes -ICLT Program
Complications of Minimal Access Surgery at WLH
VCE English Exam - Section C Student Revision Booklet
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Final Presentation General Medicine 03-08-2024.pptx
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
O5-L3 Freight Transport Ops (International) V1.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
01-Introduction-to-Information-Management.pdf
O7-L3 Supply Chain Operations - ICLT Program
Pharma ospi slides which help in ospi learning
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Cell Structure & Organelles in detailed.
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Ad

notesCHAPTER_5_tree_data_structure_ds.pppt

  • 1. Topic 5 TREE DFC 30233 DATA STRUCTURE
  • 2. 1.0 Define tree,binary tree and binary search tree BINARY TREE  A type of data structure where each parent node can have at most two child nodes  These two child nodes are known as the left child and right child.
  • 3. 1.0 Define tree,binary tree and binary search tree BINARY SEARCH TREE  A binary search tree is a binary tree in which the nodes are assigned values, with the following restrictions ; • No duplicate values • Left child node is smaller than its parent Node • Right child node is greater than its parent Node
  • 5. ― Irene M. Pepperberg
  • 6. 1.2 Terminology in relation to trees: 1. Root, 2. Parent, 3. Children, 4. Leaves, 5. Sibling, 6. Node, 7. Path, 8. Degree, 9. Level
  • 7. Root  ROOT NODE - the first node  root node is the origin of tree data structure  must be only one root node Terminology: 1. Root
  • 8. Parent Node  PARENT NODE - the node which is predecessor of any node  the node which has branch from it to any other node Terminology: 2. Parent
  • 9. Child  Child Node - the node which is descendant of any node  the node which has a link from its parent node  any parent node can have any number of child nodes  all the nodes except root are child nodes Terminology: 3. Children
  • 10. Leaf  LEAF Node - the node which does not have a child  leaf node is also called as Terminal node Terminology: 4. Leaf
  • 11. Siblings  SIBLINGS - nodes which belong to same Parent Terminology: 5. Siblings
  • 12. Internal Nodes  INTERNAL Node - the node which has at least one child  Internal nodes are also called as 'Non-Terminal' nodes Terminology: 6. Internal Nodes
  • 13. Path  PATH - the sequence of Nodes and Edges from one node to another node  Length of a Path is total number of nodes in that path.  Example: the path A - B - E - J has length 4 Terminology: 7. Path
  • 14. Degree  PATH - the sequence of Nodes and Edges from one node to another node  Length of a Path is total number of nodes in that path.  Example: the path A - B - E - J has length 4 Terminology: 8. Degree
  • 15. Edge  EDGE - the connecting link between any two nodes  In a tree with 'N' number of nodes there will be a maximum of ● 'N-1' number of edges. Terminology: 9. Edge
  • 16. Level  LEVEL - each step from top to bottom  the root node - Level 0  the children of root node - Level 1 Terminology: 10. Level
  • 17. Height  height of all leaf nodes is '0' Terminology: 11. Height
  • 18. Depth  height of all leaf nodes is '0' Terminology: 12. Depth
  • 21. 2.0 Binary Tree. Binary Tree is a tree in which every node can have a maximum of two children. Every node can have either 0 children or 1 child or 2 children but not more than 2 children.
  • 23. Perfect Binary Tree Complete Binary Tree obtained from a perfect binary tree by deleting consecutive leaves of the tree from right to left
  • 25. Example: arithmetic expression tree for the expression (2 × (a - 1)) + (3 × b) :
  • 26. Infix, Prefix and Postfix traversal An infix expression, the operator appears between its operands. In a prefix expression, places a binary operator before its operands. In a postfix expression, the binary operators comes after its operands.
  • 28. Example 1 State the order of nodes visited using prefix, infix and postfix traversal. Prefix: - 8 / 4 2 Infix: 8 – ( 4 / 2 ) Postfix: 8 4 2 / -
  • 29. Example 2 State the order of nodes visited using prefix, infix and postfix traversal. Infix form: Prefix form: Postfix form:
  • 30. a) (x+xy) + (x/y) b) x+ ((xy+x)/y) 1. Represent the expressions using binary trees. 2. Write these expressions in prefix notation. 3. Write these expressions in postfix notation. 4. Write these expressions in infix notation.
  • 31. Binary Tree Representations  A binary tree data structure is represented using two methods. Those methods are as follows.  Array Representation  Linked List Representation  Consider the following binary tree.
  • 32. 1. Array Representation 2. Linked List Representation