public BinarySortedGenericTree(T value) { _enabled = true; _value = value; _left = null; _right = null; }
public void Setup() { tree = new BinarySortedGenericTree <int>(15); foreach (int n in new List <int> { 8, 7, 23, 15, 5, 9, -1, 27, 18, 15, 14, 12, 14, 27, 10, 32, 18, 42, -4, 8, 12, 9, 2, 0 }) { tree.Insert(n); } }
IBinarySortedTree <T> InsertWithDirection(IBinarySortedTree <T> direction, T val) { if (direction == null) { direction = new BinarySortedGenericTree <T>(val); } else { direction.Insert(val); } return(direction); }
public void Insert(T val) { IBinarySortedTree <T> direction; if (_value.CompareTo(val) >= 0) { _left = InsertWithDirection(_left, val); } else { _right = InsertWithDirection(_right, val); } }