0

If we have to delete a node from a binary tree, how should we handle the children of the node being deleted. E.g. in this tree:

    100
   /
  10 
 /  \
5    20 

where 100 is the root node, 10 is left child of 100, 5 is left child of 10 and 20 is right child of 10. So after deleting 10, what will happen to 5 and 20?

Markus
  • 3,225
  • 6
  • 35
  • 47
  • 1
    Possible duplicate of [How to delete a node with 2 children nodes in a binary search tree?](https://stackoverflow.com/questions/8292661/how-to-delete-a-node-with-2-children-nodes-in-a-binary-search-tree) – spectras Jul 28 '17 at 10:35

1 Answers1

0

It is your choice if what should you do after deleting.You would probably want to move one of the child upward on some so certain criteria. Either of of Child will take place of parent.

  1. delete node in Binary Search Tree.
  2. delete node in AVL.
  3. Heapify in Heapsort.
  4. And more.

So it is always a choice you have to take to solve for objective.

Community
  • 1
  • 1
vkstack
  • 1,582
  • 11
  • 24