public void Remove(int Item, BSTNode Parent = null) { if (Item < Data) { if (Left != null) { Left.Remove(Item, this); } return; } else if (Item > Data) { if (Right != null) { Right.Remove(Item, this); } return; } if ((Left == null) && (Right == null)) { if (Parent.Left == this) { Parent.Left = null; } else { Parent.Right = null; } } else if ((Right != null) && (Left != null)) { Data = Right.MinValue(); Right.Remove(Data, this); return; } else if (Right != null) { if (Parent.Left == this) { Parent.Left = Right; } else { Parent.Right = Right; } } else if (Left != null) { if (Parent.Left == this) { Parent.Left = Left; } else { Parent.Right = Left; } } }
public void Remove(int e) { Root.Remove(e); }