This is amazing, i procrastinated so much bc i was afraid of not understanding this concept but you just solved my problem and gave me motivation again THANK YOU!
10:14 - I think it can be only cases I and II since in cases III and IV a left subrtee or both of the subtrees exist, and in such a case we would go further left-down searching for the smallest element untill we come across cases I or II. Isn't it right?
compare the picture at 4:04 with the pic at 10:14 brother....you will understand the latter....you are right in the sense that there will never be a case where a node has 2 children, ie case iV....but there cane definitely be cases where a node has 1 child, but the youtuber has categorized both case ii and case iii as cases with one child....thats the confusion....
Sir i have a question, when finding successor in 4th case, can we also do like - making 20 the successor and just simply the 5 will point to 11 as its parent. So basically the whole left part of the tree is shifted down to 11 as its parent node.
I just wantedi to ask that would'nt it be better if instead of copying the values, we somehow found a way to readjust the pointers. Because, it might be possible that I'll be pointing to that particular node elsewhere in my code. If in the removal phase, the value of that node gets tampered without my knowledge, it would be a mess, would'nt it ??
If you are concerned that data at that "saved pointer elsewhere" may be invalidated, then do not save any pointers. It's a variation on "race conditions". I see an empty table in a "food hall", so I go order a burger. Later, when I have my burger, that table is no longer empty... Ain't life a bitch! It would be a mess, too, if your "saved pointer" happens to be the one deleted by intervening operations.
@@rustycherkas8229 So what you are trying to say through this huge para is copying the values is a better decision while making BSTs instead of readjusting the pointers. According to me, while deigning the BST we should not make assumptions on how its going to be used. Just design in a way we feel the system is more robust.
@@shayaksarkar7740 If you retain pointers to nodes in multiple places, then you have multiple locii of control. A (balanced) BST works because the caller of insert() allows insert() to change which node is the root node to maintain balance. Deleting nodes can/will cause the tree to become very "unbalanced" so that even find() and insert() perform badly A "binary search tree" can decay into a simple linked list... "robust"? Then you want to "lock" the tree to prevent changes so that your tree cannot be altered while your "code somewhere else" retains control of its node... Good luck with that! It's a dynamic world. Live with it.
@@rustycherkas8229 Again ... You don't seem to make 1 point that suggests re-arranging the nodes themselves is not better than copying values. Maybe the users of the BST want to keep references to the nodes. Maybe that is what suits their design needs. "A (balanced) BST works because the caller of insert() allows insert() to change which node is the root node to maintain balance" - Okay, so what? Doesn't mean it gives permission to the nodes to change their values. If the users are using locking, let them do so. Intelligent of them. Still I don't get your point.
@@shayaksarkar7740 Try this: Your concern seems to be that the memory storing a node will be changed by 'copying' content from another node over top of it. "Code somewhere else" may be affected (expecting the content to be unchanging.) The operation is 'delete'... the memory containing a deleted node (or the 'source node' of the copy operation) will be released or recycled. Subsequent access by "code somewhere else" will cause undefined behaviour. The expectation of "code somewhere else" is flawed. Delete will cause 1 node to be released/recycled... Bad luck if "code somewhere else" has a long-term interest in ANY node & its content... Who "gives permission" for "code somewhere else" to expect nodes of a BST to remain unchanged (when deletion is available.)... 'Better' is in the eyes of the beholder...
This is by far one the best resource about Data Structure out there
This is amazing, i procrastinated so much bc i was afraid of not understanding this concept but you just solved my problem and gave me motivation again THANK YOU!
I have a data structures and algorithms exam tomorrow. I'm currently using your videos to study. Great resource 💯💯💯
your explanations of algorithms without actually giving explicit algorithms are really helpful thanks
this is the best BST removal tutorial I've seen so far!
The king of Data Structure
I can't believe there are so many paid materials out there that do not even come close to how clear your videos are...
You are the best. The way the explain is far better than my university professor.
Great explanation! Out of all the videos I’ve watched this is the one which clicked perfect with me.
Just want to say thank you, this channel is so good!!!!!!
Phenomenal explanation and demonstration, with great examples! This was a perfect refresher while preparing for my final exam. Thank you.
wonderful explanation, kudos to your efforts!
Clear explanation and easy to understand
Very helpful!
10:14 - I think it can be only cases I and II since in cases III and IV a left subrtee or both of the subtrees exist, and in such a case we would go further left-down searching for the smallest element untill we come across cases I or II. Isn't it right?
compare the picture at 4:04 with the pic at 10:14 brother....you will understand the latter....you are right in the sense that there will never be a case where a node has 2 children, ie case iV....but there cane definitely be cases where a node has 1 child, but the youtuber has categorized both case ii and case iii as cases with one child....thats the confusion....
Best Explanation Ever!!
Thank you so much! You made the whole concept so easy to understand)
Thanks!
Hey, just in general thanks for the videos man, helping me out with my course work
Very well explained! Thank you so much, I really appreciate it ♥!
Perfect explanation !
Sir i have a question, when finding successor in 4th case, can we also do like - making 20 the successor and just simply the 5 will point to 11 as its parent. So basically the whole left part of the tree is shifted down to 11 as its parent node.
I just wantedi to ask that would'nt it be better if instead of copying the values, we somehow found a way to readjust the pointers. Because, it might be possible that I'll be pointing to that particular node elsewhere in my code. If in the removal phase, the value of that node gets tampered without my knowledge, it would be a mess, would'nt it ??
If you are concerned that data at that "saved pointer elsewhere" may be invalidated, then do not save any pointers. It's a variation on "race conditions".
I see an empty table in a "food hall", so I go order a burger. Later, when I have my burger, that table is no longer empty... Ain't life a bitch!
It would be a mess, too, if your "saved pointer" happens to be the one deleted by intervening operations.
@@rustycherkas8229 So what you are trying to say through this huge para is copying the values is a better decision while making BSTs instead of readjusting the pointers. According to me, while deigning the BST we should not make assumptions on how its going to be used. Just design in a way we feel the system is more robust.
@@shayaksarkar7740 If you retain pointers to nodes in multiple places, then you have multiple locii of control. A (balanced) BST works because the caller of insert() allows insert() to change which node is the root node to maintain balance. Deleting nodes can/will cause the tree to become very "unbalanced" so that even find() and insert() perform badly A "binary search tree" can decay into a simple linked list...
"robust"? Then you want to "lock" the tree to prevent changes so that your tree cannot be altered while your "code somewhere else" retains control of its node... Good luck with that!
It's a dynamic world. Live with it.
@@rustycherkas8229 Again ... You don't seem to make 1 point that suggests re-arranging the nodes themselves is not better than copying values. Maybe the users of the BST want to keep references to the nodes. Maybe that is what suits their design needs.
"A (balanced) BST works because the caller of insert() allows insert() to change which node is the root node to maintain balance" - Okay, so what? Doesn't mean it gives permission to the nodes to change their values.
If the users are using locking, let them do so. Intelligent of them. Still I don't get your point.
@@shayaksarkar7740 Try this:
Your concern seems to be that the memory storing a node will be changed by 'copying' content from another node over top of it.
"Code somewhere else" may be affected (expecting the content to be unchanging.)
The operation is 'delete'... the memory containing a deleted node (or the 'source node' of the copy operation) will be released or recycled. Subsequent access by "code somewhere else" will cause undefined behaviour.
The expectation of "code somewhere else" is flawed.
Delete will cause 1 node to be released/recycled... Bad luck if "code somewhere else" has a long-term interest in ANY node & its content...
Who "gives permission" for "code somewhere else" to expect nodes of a BST to remain unchanged (when deletion is available.)...
'Better' is in the eyes of the beholder...
wa7esh we7yet emme
tfuck, how? how can this guy be so genius!!! Love your content
Great video. Earned a subscriber
perfect explanation. tnx a lot!
This is really very heplful! thanks
Great video!
Just wanted to say thank you :)
Thank you 👏🙏🙏
You are a legend
awesome video.
Thanks Sir.
How can I repay you William.Thank you.I hope you are fine
Thank you so much!
THANK FOR THIS VIDEO,!!!!!!!!!!!!!
best one
BESTT