Question: c ) How would you modify deletion? Your modification should exhibit the same time complexity as ordinary deletion. Input: victim: BST node to be deleted

c) How would you modify deletion? Your modification should exhibit
the same time complexity as ordinary deletion.
Input: victim: BST node to be deleted
Input: BST.Delete
1 Let children be the number of non-nil children of victim
2 if children =0 then
3 if victim.parent = nil then
4 Set victim.parents matching child pointer to nil
5 end
6 delete victim
7 else if children =1 then
8 Let child be the child of victim
9 if victim.parent = nil then
10 Set victim.parents matching child pointer to child
11 end
12 child.parent = victim.parent
13 delete victim
14 else
15 lhsM ax = victim.left
16 while lhsM ax.right = nil do
17 lhsM ax = lhsM ax.right
18 end
19 Swap victim.data and lhsM ax.data
20 BST.Delete(lhsM ax)
21 end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!