BST_(1)[1]
BST_(1)[1]
10
/ \
8 11
/\ \
6 9 12
\
14
\
18
/\
16 36
10
/ \
8 11
\ \
9 12
\
14
\
18
/\
16 36
Step 3: Deleting Key 14
10
/ \
8 11
\ \
9 12
\
18
/\
16 36
Node 12 is a node with one child (18). We can simply remove it by linking its parent directly to its
child.
10
/ \
8 11
\ \
9 18
/\
16 36
Create a binary search tree (BST) from the numbers 10, 13, 16, 8, 5, 9, 12, 14, and 6, and then delete
the keys 10, 6, and 143 one after the other while show the trees at each stage.
10
/ \
8 13
/\ /\
5 9 12 16
\
6
Node 10 has two children (8 and 13). We find its inorder successor (the smallest node in its right
subtree), which is 12. We replace 10 with 12 and then delete 12.
12
/ \
8 13
/\ \
5 9 16
\
6
12
/ \
8 13
/\ \
5 9 16
Step 4: Deleting Key 143
Key 143 does not exist in the tree. Therefore, no changes are made.
12
/ \
8 13
/\ \
5 9 16
Create a binary search tree (BST) from the numbers 5, 3, 7, 2, 4 and then delete the keys 3 and 4
Step 1: Constructing the BST
5
/\
3 7
/\
2 4
Node 3 has two children (2 and 4). We replace it with its inorder successor (4).
5
/\
4 7
/
2
Step 3: Deleting Key 5
4
/
2
\
Create a binary search tree (BST) from the numbers 8, 6, 10, 5, 7 and then delete the keys 6 and 8
8
/\
6 10
/\
5 7
Node 6 has two children (5 and 7). We replace it with its inorder successor (7).
8
/\
7 10
/
5
7
/
5
Create a binary search tree (BST) from the numbers 15, 10, 20, 8, 12 and then delete the keys 10
and 15
1. Insert 15 as root.
2. Insert 10 as left child of root.
3. Insert 20 as right child of root.
4. Insert 8 as left child of node with key 10.
5. Insert 12 as right child of node with key 10.
15
/\
10 20
/\
8 12
Node 10 has two children (8 and 12). We replace it with its inorder successor (12).
15
/\
12 20
/
8
---
These questions provide a simpler understanding of constructing a binary search tree and
performing deletion operations while maintaining its properties!