I'm having trouble removing nodes from a binary search tree that I'm implementing. In the particular method below, I made it so that the node that I want to get rid of is overridden by its child. In this case, I'm trying to get rid of the minimum, so either there is one child or none. However, when I view all the elements of the tree after doing one deletion, the element I deleted is still showing up. What am I doing wrong here?
if(r.left != null)
{
return deleteMin(r.left);
}
if(r.right != null)
{
AnyType data = (AnyType) r.items.data;
r = r.right;
return data;
}
AnyType data = (AnyType) r.items.data;
r = null;
return data;

New Topic/Question
Reply



MultiQuote






|