平均および最悪の場合の時間の複雑さを見つけるのは少し難しいです。したがって、次のロジックでこの BST ノードの削除を行いました
二分探索木でノードを削除する場合、3 つのケースがあります。
1> The node to delete has no children. That's easy: just release its resources and you're done. Time complexity O(1)
2> The node has a single child node. Release the node and replace it with its child, so the child holds the removed node's place in the tree. Time complexity O(1)
3> The node has two children. Find the right-most child of node's left subtree. Assign its value to root, and delete this child. **Here time compexity can be maximum O(N)**
To find the node to be deleted can be **maximum O(N)**
では、全体の平均と最悪の時間の複雑さをどのように計算しますか??