0% found this document useful (0 votes)
39 views

Lecture 10.1

This document provides an outline for a lecture on binary search trees. It discusses deleting nodes from a binary search tree in three cases: when the node is a leaf, has one child, or has two children. It also includes an exercise to build a binary search tree by inserting elements and then deleting three elements. References and book recommendations are provided at the end.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views

Lecture 10.1

This document provides an outline for a lecture on binary search trees. It discusses deleting nodes from a binary search tree in three cases: when the node is a leaf, has one child, or has two children. It also includes an exercise to build a binary search tree by inserting elements and then deleting three elements. References and book recommendations are provided at the end.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Binary Search Tree

Course Code: CSC 2106 Course Title: Data Structure (Theory)

Dept. of Computer Science


Faculty of Science and Technology

Lecturer No: 10.1 Week No: 10 Semester: Fall 2020-2021


Lecturer: MAHFUJUR RAHMAN, [email protected]
Lecture Outline

1. Binary Search Tree Deletion


2. Exercise
Binary Search Tree
Deletion

Delete 47 (leaf node) – Case 1


Replace with the child 43
Delete 40 (have only one child) – Case 2 Replace with the child
with the highest value
Delete 64 & 31 (have both child) – Case 3 with the highest value
from left sub-tree or 32 from left sub-tree or
31
with the lowest value
from right subtree with the lowest value 64
59
from right subtree
40
Node with one child: 20
connect the parent to 38 56 89
the child and Delete
28
32 47 59
Node with one child: connect the
parent to the child and Delete
33 Leaf
LeafNode:
Node:Just
JustDelete
Delete
Binary Search Tree
Exercise

Insert the following elements one by one to build a BST:

45, 34, 61, 22, 30, 57, 48, 60, 40, 90, 39, 44, 41

Now delete 34, 40 and 45 from the BST


References

1. https://en.wikipedia.org/wiki/Binary_Search_Tree
Books
 “Schaum's Outline of Data Structures with C++”. By John R. Hubbard
 “Data Structures and Program Design”, Robert L. Kruse, 3rd Edition, 1996.
 “Data structures, algorithms and performance”, D. Wood, Addison-Wesley, 1993
 “Advanced Data Structures”, Peter Brass, Cambridge University Press, 2008
 “Data Structures and Algorithm Analysis”, Edition 3.2 (C++ Version), Clifford A.
Shaffer, Virginia Tech, Blacksburg, VA 24061 January 2, 2012
 “C++ Data Structures”, Nell Dale and David Teague, Jones and Bartlett Publishers,
2001.
 “Data Structures and Algorithms with Object-Oriented Design Patterns in C++”,
Bruno R. Preiss,

You might also like