Download presentation
Presentation is loading. Please wait.
1
Binary search tree. Removing a node
2
There are three cases ◦Case 1: Node to be deleted has no children.
◦Case 2: Node to be deleted has one child. ◦Case 3: Node to be deleted has two children.
3
◦Case 1: Node to be deleted has no children
4
◦Case 1: Node to be deleted has no children
5
◦Case 2: Node to be deleted has one child.
6
◦Case 2: Node to be deleted has one child.
7
◦Case 3: Node to be deleted has two children
8
◦Case 3: Node to be deleted has two children
9
◦Case 3: Node to be deleted has two children
Find minimum element in the right subtree of the node to be removed. In current example it is 19
10
◦Case 3: Node to be deleted has two children
Replace 12 with 19. Notice, that only values are replaced, not nodes. Now we have two nodes with the same value.
11
◦Case 3: Node to be deleted has two children
Remove 19 from the left subtree.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.