consider a tree of height 4 you need to delete a node from level 2 the node to be deleted has two children which approach should be used to delete it ?
Answers
Answered by
13
Answer: Node to be deleted is the leaf: Simply remove from the tree. · 2) Node to be deleted has only one child: Copy the child to the node and delete
Explanation:
Answered by
0
Answer: The approach is explained below
Successor: The lowest node of the tree that is strictly bigger than the current node is considered to be the successor of a node in a binary tree.
Predecessor: The higher node of the tree that is strictly lower than the current node is considered to be the predecessor of a node in a binary tree.
Explanation:
Node has two children
- first determine the current node's successor (or predecessor).
- Delete the successor (or predecessor) from the tree
- Replace the node to be removed with the successor (or predecessor) (or predecessor)
#SPJ3
Similar questions