The idea of removing node in BST:
If the node does not have a child, delete it and update the parent pointer to this node as null
If the node has one child, replace the node with its children by updating the node's parent pointer with its child
If the node has two children, find the predecessor of the node and replace it with your predecessor, also update the parent pointer of the predecessor by pointing to its only child (which can only be a left child)
the latter case can also be accomplished using a successor instead of a predecessor!
He said that if we use the predecessor in some cases and the successor in some other cases (giving them equal priority), we can have better empirical performance,
Now the question is, how is this done? based on what strategy? and how does it affect performance? (I think in terms of performance they mean time complexity)
I think we should choose a predecessor or successor in order to have a more balanced tree! but I don’t know how to choose which one to use!
One solution is to randomly select one of them (just chance), but is it not better to have a strategy based on a tree structure? but the question is: WHEN choose WHICH?
source share