You are on page 1of 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, mahfuj@aiub.edu
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