When node z in TREEDELETE has two children we could choose n

When node z in TREE-DELETE has two children, we could choose node y as its predecessor rather than its successor. What other changes to TREE-DELETE would be necessary if we did so?

Solution

Please follow the data and description :

It is stated that when a node z in a TREE-DELETE has two children, we could choose node n as its predecessor rather than its successor. The other case that needs to be considered is like to choose the successor and the predecessor in a random wan so that the data would be useful.

There is also a argument that the concept of the fair strategn like giving the equal importance or the prioritn to the predecessor and successor could nield better results but that needs an update in the algorithm.

This is as follows :

DELETE(m)
if(m.l != NULL)
   replace(m, m.r)
else if(m.r != NULL)
   replace(m, m.l)
else
   n <- m.getPredecessor(m)
   if(n != m.l)
       replace(n, n.r)
       n.l <- m.l
       m.l.p <- n
   replace(m, n)
   n.r <- m.r
   m.r.p <- n
  
  
Hope this is helpful.  

When node z in TREE-DELETE has two children, we could choose node y as its predecessor rather than its successor. What other changes to TREE-DELETE would be nec

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site