SlideShare a Scribd company logo
1 of 12
DATA STRUCTURE
TREE
DATA STRUCTURE - TREE
 Many applications are
hierarchical in nature.
 Linear data structures are not
appropriate for these type of
applications.
Tree  2
President
Vice President
Executive Executive
Vice President
Executive
Vice President
Executive Executive
Mashrafi Khan
Mairufa Khan
Junayed
Ahmed
Masrufa
Ahmed
Fahim Khan
Ashfar
Khan
Moin Khan
Imran
Khan
Bushra
Khan
Faizul Khan
Mahboob
Khan
Mashrufa
Khan
Mashraba
Khan
Hierarchical structure of a company
Genealogy tree of a family
COMMON USE OF TREE AS A DATA STRUCTURE
 Representing hierarchical data
 Storing data in a way that makes it easily searchable
 Representing sorted lists of data
 As a workflow for compositing digital images for visual effects
 Routing algorithms
Tree  3
TREE - DEFINITION
 As a data structure, a tree consists of one
or more nodes, where each node has a
value and a list of references to other (its
children) nodes.
 A tree must have a node designated as
root. If a tree has only one node, that
node is the root node. Root is never
referenced by any other node.
 Having more than one node indicates that
the root have some (at least one)
references to its children nodes and the
children nodes (might) have references to
their children nodes and so on.
Tree  4
A
B C D
E F JIHG
K ML ON
ROOT
VALUE
CHILDCHILD
TREE - DEFINITION
 Generally it is considered that in a tree,
there is only one path going from one
node to another node.
 There cannot be any cycle or loop.
 The link from a node to other node is
called an edge.
 An arrowed edge
indicates flow from P to Q.
 An straight line edge
indicates flow from P to Q and Q to P.
Tree  5
A
B C D
E F JIHG
K ML ON
If node F is reached through node B, than the link from
node K to node F will not be considered.
If link from node L to node C is considered, than there
will be a cycle among nodes C, G, and L.
P Q
P Q
A straight line is generally used to represent the links
between the nodes of a tree.
TREE - DEFINITION
 Nodes
 Parent Nodes & Child Nodes
 Leaf Nodes: nodes with no child
 Root Node: node with no parent
 Sub Tree: the tree rooted by a child
 Level of a tree:
 Root at level 0;
 Each children have the level one more than
its parent.
 Height/depth of the tree: Total
number of Levels
 Height of a node: Total number of
levels from bottom
[Tree height – node level].
Tree  6
A
B C D
E F JIHG
K ML ON
LEVEL
0
1
2
3
Height of this tree is 4, as there are four levels (0…3).
Height of root A is 4;
Height of nodes B, C, D is 3;
Height of E, F, G, H, I, J is 2;
Height of nodes K, L , M, N, O is 1.
m-ARY TREE
 A Tree is an m-ary Tree when each of its node has no more than m children.
Tree  7
A
B C D
E F JIHG
K ML ON
A
B D
E F IH
GK
ML
ON
2-ary tree 3-ary tree
BINARY TREE (BT)
 Each node of a binary Tree has at most 2 children.
Tree  8
A
B D
E F IH
GK
ML
ON
Binary tree
BINARY SEARCH TREE (BST)
 Is a Binary Tree such that:
 Every node entry has a unique key (i.e. no duplication item).
 All the keys in the left subtree of a node are less than the key of the node.
 All the keys in the right subtree of a node are greater than the key of the node.
Tree  9
43
31 64
20 40 8956
3328 47 59
Fred
Dan Mary
Alan Eve SueKate
EricBill Greg Len
Integer Key String Key
BST - INSERT
Tree  10
43
31 64
20 40 8956
3328 47 59
> <
< <
<><
>
>
>
Fred
Dan Mary
Alan Eve SueKate
EricBill Greg Len
> <
< >
> <<
>
>
<
Integer Key String Key
43 31 64 40 20 89 56 47 33 28 59Fred Mary Kate Dan Len Alan Eve Bill Sue Greg Eric
BST - SEARCH
 Search Elements 59 and 42
Fahad Ahmed CSC 2015: Data Structures Tree  11
43
31 64
20 40 8956
3328 47 59
43 < 59
64 > 59
56 < 59
59 = 59
43 > 42
31 < 42
40 < 42
? 42
BST - DELETE
 Delete 47 (leaf node);
 Delete 40 (have only one child);
 Delete 64 and 31 (have both child).
Tree  12
43
31 64
20 40 8956
3828 47 59
32
33
5932
Leaf Node: Just DeleteLeaf Node: Just Delete
Node with one child:
connect the parent to
the child and Delete
Node with one child: connect the
parent to the child and Delete
Node with two
children on right
subtree: Replace with
the child with highest
value either from left
or right subtree
Node with two
children on left
subtree: Replace with
the child with lowest
value either from left
or right subtree

More Related Content

What's hot

Data Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeData Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeManishPrajapati78
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search TreeAbhishek L.R
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures treemaamir farooq
 
data structure
data structuredata structure
data structurehashim102
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked listchauhankapil
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of AlgorithmsArvind Krishnaa
 
Computer notes - Expression Tree
Computer notes - Expression TreeComputer notes - Expression Tree
Computer notes - Expression Treeecomputernotes
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data StructureDharita Chokshi
 
Trees - Non Linear Data Structure
Trees - Non Linear Data StructureTrees - Non Linear Data Structure
Trees - Non Linear Data StructurePriyanka Rana
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary treeZaid Shabbir
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - GraphMadhu Bala
 
Binary search tree
Binary search treeBinary search tree
Binary search treeKousalya M
 

What's hot (20)

Data Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary TreeData Structure and Algorithms Binary Tree
Data Structure and Algorithms Binary Tree
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Tree in data structure
Tree in data structureTree in data structure
Tree in data structure
 
Lecture notes data structures tree
Lecture notes data structures   treeLecture notes data structures   tree
Lecture notes data structures tree
 
data structure
data structuredata structure
data structure
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
Tree
TreeTree
Tree
 
Trees
TreesTrees
Trees
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Computer notes - Expression Tree
Computer notes - Expression TreeComputer notes - Expression Tree
Computer notes - Expression Tree
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 
DFS and BFS
DFS and BFSDFS and BFS
DFS and BFS
 
Binary Search Tree in Data Structure
Binary Search Tree in Data StructureBinary Search Tree in Data Structure
Binary Search Tree in Data Structure
 
Trees - Non Linear Data Structure
Trees - Non Linear Data StructureTrees - Non Linear Data Structure
Trees - Non Linear Data Structure
 
Tree and binary tree
Tree and binary treeTree and binary tree
Tree and binary tree
 
2.5 dfs & bfs
2.5 dfs & bfs2.5 dfs & bfs
2.5 dfs & bfs
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
Linked list
Linked list Linked list
Linked list
 
Binary search tree
Binary search treeBinary search tree
Binary search tree
 
Trees data structure
Trees data structureTrees data structure
Trees data structure
 

Similar to Data structure tree - beginner (20)

Data structure tree - intermediate
Data structure tree - intermediateData structure tree - intermediate
Data structure tree - intermediate
 
Data structure tree- advance
Data structure tree- advanceData structure tree- advance
Data structure tree- advance
 
Dsc++ unit 3 notes
Dsc++ unit 3 notesDsc++ unit 3 notes
Dsc++ unit 3 notes
 
Tree and Binary Search tree
Tree and Binary Search treeTree and Binary Search tree
Tree and Binary Search tree
 
Binary tree
Binary treeBinary tree
Binary tree
 
Unit 4.1 (tree)
Unit 4.1 (tree)Unit 4.1 (tree)
Unit 4.1 (tree)
 
Chapter 8: tree data structure
Chapter 8:  tree data structureChapter 8:  tree data structure
Chapter 8: tree data structure
 
17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal17. Java data structures trees representation and traversal
17. Java data structures trees representation and traversal
 
NON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptxNON-LINEAR DATA STRUCTURE-TREES.pptx
NON-LINEAR DATA STRUCTURE-TREES.pptx
 
part4-trees.ppt
part4-trees.pptpart4-trees.ppt
part4-trees.ppt
 
Binary tree and operations
Binary tree and operations Binary tree and operations
Binary tree and operations
 
Trees in data structures
Trees in data structuresTrees in data structures
Trees in data structures
 
Unit iii(dsc++)
Unit iii(dsc++)Unit iii(dsc++)
Unit iii(dsc++)
 
Unit 3.ppt
Unit 3.pptUnit 3.ppt
Unit 3.ppt
 
Tree.pptx
Tree.pptxTree.pptx
Tree.pptx
 
Tree 11.ppt
Tree 11.pptTree 11.ppt
Tree 11.ppt
 
B+ trees and height balance tree
B+ trees and height balance treeB+ trees and height balance tree
B+ trees and height balance tree
 
Lect 19 Zaheer Abbas
Lect 19 Zaheer AbbasLect 19 Zaheer Abbas
Lect 19 Zaheer Abbas
 
Lect 21 Zaheer Abbas
Lect 21 Zaheer AbbasLect 21 Zaheer Abbas
Lect 21 Zaheer Abbas
 
Unit 2_1 Tree.pdf
Unit 2_1 Tree.pdfUnit 2_1 Tree.pdf
Unit 2_1 Tree.pdf
 

Recently uploaded

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 

Recently uploaded (20)

ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 

Data structure tree - beginner

  • 2. DATA STRUCTURE - TREE  Many applications are hierarchical in nature.  Linear data structures are not appropriate for these type of applications. Tree  2 President Vice President Executive Executive Vice President Executive Vice President Executive Executive Mashrafi Khan Mairufa Khan Junayed Ahmed Masrufa Ahmed Fahim Khan Ashfar Khan Moin Khan Imran Khan Bushra Khan Faizul Khan Mahboob Khan Mashrufa Khan Mashraba Khan Hierarchical structure of a company Genealogy tree of a family
  • 3. COMMON USE OF TREE AS A DATA STRUCTURE  Representing hierarchical data  Storing data in a way that makes it easily searchable  Representing sorted lists of data  As a workflow for compositing digital images for visual effects  Routing algorithms Tree  3
  • 4. TREE - DEFINITION  As a data structure, a tree consists of one or more nodes, where each node has a value and a list of references to other (its children) nodes.  A tree must have a node designated as root. If a tree has only one node, that node is the root node. Root is never referenced by any other node.  Having more than one node indicates that the root have some (at least one) references to its children nodes and the children nodes (might) have references to their children nodes and so on. Tree  4 A B C D E F JIHG K ML ON ROOT VALUE CHILDCHILD
  • 5. TREE - DEFINITION  Generally it is considered that in a tree, there is only one path going from one node to another node.  There cannot be any cycle or loop.  The link from a node to other node is called an edge.  An arrowed edge indicates flow from P to Q.  An straight line edge indicates flow from P to Q and Q to P. Tree  5 A B C D E F JIHG K ML ON If node F is reached through node B, than the link from node K to node F will not be considered. If link from node L to node C is considered, than there will be a cycle among nodes C, G, and L. P Q P Q A straight line is generally used to represent the links between the nodes of a tree.
  • 6. TREE - DEFINITION  Nodes  Parent Nodes & Child Nodes  Leaf Nodes: nodes with no child  Root Node: node with no parent  Sub Tree: the tree rooted by a child  Level of a tree:  Root at level 0;  Each children have the level one more than its parent.  Height/depth of the tree: Total number of Levels  Height of a node: Total number of levels from bottom [Tree height – node level]. Tree  6 A B C D E F JIHG K ML ON LEVEL 0 1 2 3 Height of this tree is 4, as there are four levels (0…3). Height of root A is 4; Height of nodes B, C, D is 3; Height of E, F, G, H, I, J is 2; Height of nodes K, L , M, N, O is 1.
  • 7. m-ARY TREE  A Tree is an m-ary Tree when each of its node has no more than m children. Tree  7 A B C D E F JIHG K ML ON A B D E F IH GK ML ON 2-ary tree 3-ary tree
  • 8. BINARY TREE (BT)  Each node of a binary Tree has at most 2 children. Tree  8 A B D E F IH GK ML ON Binary tree
  • 9. BINARY SEARCH TREE (BST)  Is a Binary Tree such that:  Every node entry has a unique key (i.e. no duplication item).  All the keys in the left subtree of a node are less than the key of the node.  All the keys in the right subtree of a node are greater than the key of the node. Tree  9 43 31 64 20 40 8956 3328 47 59 Fred Dan Mary Alan Eve SueKate EricBill Greg Len Integer Key String Key
  • 10. BST - INSERT Tree  10 43 31 64 20 40 8956 3328 47 59 > < < < <>< > > > Fred Dan Mary Alan Eve SueKate EricBill Greg Len > < < > > << > > < Integer Key String Key 43 31 64 40 20 89 56 47 33 28 59Fred Mary Kate Dan Len Alan Eve Bill Sue Greg Eric
  • 11. BST - SEARCH  Search Elements 59 and 42 Fahad Ahmed CSC 2015: Data Structures Tree  11 43 31 64 20 40 8956 3328 47 59 43 < 59 64 > 59 56 < 59 59 = 59 43 > 42 31 < 42 40 < 42 ? 42
  • 12. BST - DELETE  Delete 47 (leaf node);  Delete 40 (have only one child);  Delete 64 and 31 (have both child). Tree  12 43 31 64 20 40 8956 3828 47 59 32 33 5932 Leaf Node: Just DeleteLeaf Node: Just Delete Node with one child: connect the parent to the child and Delete Node with one child: connect the parent to the child and Delete Node with two children on right subtree: Replace with the child with highest value either from left or right subtree Node with two children on left subtree: Replace with the child with lowest value either from left or right subtree