How to Delete a Node from a Binary Search Tree

preview_player
Показать описание
In this video I walk through how to delete nodes from a binary search tree. Specifically I explain how to delete: the root node, a node with one child, a node with two children, and a leaf node.
Рекомендации по теме
Комментарии
Автор

4 minutes vs 1:10h video on the same topic, yours helped me 1000x more

emilianbucewka
Автор

This is misleading, you skipped an important note.
When removing a node with 2 children then you want to search for its predecessor.
The predecessor is the biggest node in the left tree that doesn't have a right node.
This is a key point.

MoeHaydar
Автор

Which one is Correct?
While Removing node with two children, we have to pick the smallest node in the Right subtree?
or the biggest Node in the Left Subtree?

AzatDzhanybekov
Автор

ThankYOU, helped a lot for my tomorrow exam
 

chiragpokharia
Автор

Hi, I like the animation style of these videos and would like to do something similar for a simple presentation I have to give. What tool did you guys use to create these animations? Any help much appreciated! Thanks!

JesseSalazar
Автор

I have a question though, when he removed nine, isn't he supposed to find for the min in the right child and use that as a replacement to the removed node?

yaakouv
Автор

the best explanation I could find, U realy good man

INSULTKARI
Автор

Your description is incomplete if not wrong when deleting a node that has two children. here is what you have to do:

if node has two children, on the left subtree(which can be a huge tree itself) find the biggest value which is the last right Node. take that and replace it which the node to remove. if the max node of left sub tree has a sub left tree, refrence it to its parent(your recursive algorithm does it automtically.) but if it doesnt have left sub tree and of course it doest have right sub tree, make that node null.

try it with a node that has a larger left sub tree and see how the algorithm works.

the alternative is to find the smallest node on the right sub tree ...

hadihonarvarnazari
Автор

if to delete 007 below 005 how should we do this

crickettaped
Автор

wow good explanation but i have this Q one of my boy ask me this 
*. How i can Write a program that integers 1 to 20 to a binary search tree. Assume the root node is created with       value 10.
**  Assume the data structure:
StructNode{
Int value;
Node*next;
        };
      Node *head=NULL;
 Assume also that there is a value 10 in the linked list.Write a code that deletes a node with this value.Consider all the following cases:
a. The node is at the head
b. The node is at the middle
c. The node is at the end
Show less

andualem
Автор

Thanks, but this is only a explanation visually. I think in computer science especially in code, when there is no picture visually, the logic of removing a non-leaf node should be based on its child or child's child, which lacks of explanation in this video, in terms of programmatic logic.

shrukge
Автор

what if, say 3 had such a child as 2.5?

michaelwpannekoek
visit shbcf.ru