private SimpleBinarySearchTree <TLabel> Remove(TLabel label) { int compare = this.Label.CompareTo(label); if (compare < 0) { if (this.LeftChild != null) { this.LeftChild = this.LeftChild.Remove(label); } return(this); } if (compare > 0) { if (this.RightChild != null) { this.RightChild = this.RightChild.Remove(label); } return(this); } if (this.LeftChild == null) { return(this.RightChild); } if (this.RightChild == null) { return(this.LeftChild); } var newLabel = this.LeftChild.RightMostChild.Label; this.LeftChild = this.LeftChild.Remove(newLabel); this.Label = newLabel; return(this); }
private SimpleBinarySearchTree(TLabel label, SimpleBinarySearchTree <TLabel> parent) { this.Label = label; this.parent = parent; }
public SimpleBinarySearchTree(TLabel label) { this.Label = label; this.parent = null; }