BST Deletion
There are also some cases while deleting nodes from the tree:
- Deleting the leaf node;
- Deleting the node with 1 child;
- Deleting the node with 2 children.
Deleting the leaf node
We may simple remove the leaf node without any crucial changes in the tree.
Deleting the node with 1 child:
-
Replace that node with its child node;
-
Remove the child node from its original position.
Deleting the node with 2 children:
-
Get the inorder successor of that node;
-
Replace the node with the inorder successor;
-
Remove the inorder successor from its original position.
Tack för dina kommentarer!
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Ställ mig frågor om detta ämne
Sammanfatta detta kapitel
Visa verkliga exempel
Awesome!
Completion rate improved to 4.35
BST Deletion
Svep för att visa menyn
There are also some cases while deleting nodes from the tree:
- Deleting the leaf node;
- Deleting the node with 1 child;
- Deleting the node with 2 children.
Deleting the leaf node
We may simple remove the leaf node without any crucial changes in the tree.
Deleting the node with 1 child:
-
Replace that node with its child node;
-
Remove the child node from its original position.
Deleting the node with 2 children:
-
Get the inorder successor of that node;
-
Replace the node with the inorder successor;
-
Remove the inorder successor from its original position.
Tack för dina kommentarer!