Binary Search Tree - Deletion Pseudo Code

preview_player
Показать описание
Video 68 of a series explaining the basic concepts of Data Structures and Algorithms.

This video explains the pseudo code for deletion from a binary search tree.

This video is meant for educational purposes only.
Рекомендации по теме
Комментарии
Автор

What about the case where we want to delete the root node, getParent will return null, we need to handle that manually

sumanth
Автор

Well structured explanation, great job!

dreamzsiva
Автор

node ret=x???
what is ret why we are returning it

virajgavas
Автор

if you are making i.left=x.left and i.right=x.right for two child then redundancy arises. please go through that and correct it.

nature-world
Автор

I think you need to remove Node i as well in the case of TwoChild(). As you have replaced the data of the node to be deleted with the other node, but the other node is still present in the tree. U need to delete that node as well.

robinck
Автор

Tq for helping me in the exam point of view

akulaakanksha
Автор

Not all of the cases were covered in the video! Assume we have node 15 which is the right sub-tree of the root 10. Assume 15 has a left child 13. And assume it has a right child 21. Furthermore, 21 has a left child 19 and right child 25. Lastly, 19 has a right child 20. If you are reading this, I encourage you to draw out this tree. Here is the case this video did not cover: if you want to delete the node 15, then what you are doing is setting the parent's left or right to the new successor (in this case, setting root's right to the successor). In this example, the successor is 19. Then you are setting the successor's left and right child to the left and right child of x (x is the node we want to delete). However, successor had a right child (20) and you replaced that with the x's right child.

tarakhanal
Автор

15.29...we replace x node with i node..
children of x will become children of i...
what about children of i?
they will be lost...

ms-lkbw
Автор

If question is give write an algorithm to delete binary search tree can we write pseudo code in the place algorithm

mohammedabrarahmed