我很难找出平均和最坏情况的时间复杂度。所以我用以下逻辑删除了这个 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)**
那么如何计算总体平均时间复杂度和最差时间复杂度?