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: BSTDelete
Let children be the number of nonnil children of victim
if children then
if victim.parent nil then
Set victim.parents matching child pointer to nil
end
delete victim
else if children then
Let child be the child of victim
if victim.parent nil then
Set victim.parents matching child pointer to child
end
child.parent victim.parent
delete victim
else
lhsM ax victim.left
while lhsM axright nil do
lhsM ax lhsM axright
end
Swap victim.data and lhsM axdata
BSTDeletelhsM ax
end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
