Update index.md (#24020)
This commit is contained in:
committed by
Christopher McCormack
parent
a3773d7c3a
commit
108884cbba
@ -47,9 +47,9 @@ It is very similar to the search function. You again start at the root of the tr
|
||||
There are 3 cases that can happen when you are trying to delete a node. If it has,
|
||||
1. No subtree (no children): This one is the easiest one. You can simply just delete the node, without any additional actions required.
|
||||
2. One subtree (one child): You have to make sure that after the node is deleted, its child is then connected to the deleted node's parent.
|
||||
3. Two subtrees (two children): You have to find and replace the node you want to delete with its successor (the leftfmost node in the right subtree).
|
||||
3. Two subtrees (two children): You have to find and replace the node you want to delete with its inorder successor (the leftmost node in the right subtree).
|
||||
|
||||
The time complexity for creating a tree is `O(1)`. The time complexity for searching, inserting or deleting a node depends on the height of the tree `h`, so the worst case is `O(h)`.
|
||||
The time complexity for creating a tree is `O(1)`. The time complexity for searching, inserting or deleting a node depends on the height of the tree `h`, so the worst case is `O(h)` in case of skewed trees.
|
||||
|
||||
#### Predecessor of a node
|
||||
Predecessors can be described as the node that would come right before the node you are currently at. To find the predecessor of the current node, look at the right-most/largest leaf node in the left subtree.
|
||||
|
Reference in New Issue
Block a user