For an unbalanced binary search tree how do you remove a lea

For an unbalanced binary search tree: how do you remove a leaf node? how do you remove a node with one child? how do you remove a node with two children?

Solution

Let assume N is node to be removed

a)If N is leaf then just remove its links from parent .No need of special procedure.

b)If N has one child,then N is directly removed from tree and its only one child is adopted by Parent of N.Link child of N to parent to parent of N and remove N.

c)If N has two children,then its content is replaced by inorder successor i.e.next immediate node that comes first in inorder and after replacing that N by node,node is deleted

 For an unbalanced binary search tree: how do you remove a leaf node? how do you remove a node with one child? how do you remove a node with two children?Soluti

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site