public static BinaryTree <T> Create <T>(params T[] values) where T : IComparable { var tree = new BinaryTree <T>(); foreach (var value in values) { tree.Add(value); } return(tree); }
public static BinaryTree <TParametrs> Create(params TParametrs[] value) { BinaryTree <TParametrs> tree = new BinaryTree <TParametrs>(); for (int i = 0; i < value.Length; i++) { tree.Add(value[i]); } return(tree); }
public static BinaryTree <T> Create(params T[] elements) { BinaryTree <T> tree = new BinaryTree <T>(); foreach (var element in elements) { tree.Add(element); } return(tree); }
public static BinaryTree <T> Create <T>(params T[] items) where T : IComparable { var tree = new BinaryTree <T>(); foreach (T item in items) { tree.Add(item); } return(tree); }
public void Add(T value) { if (tree.Count == 0) { Value = value; } else if (Value.CompareTo(value) >= 0) { Left = Left ?? new BinaryTree <T>(); Left.Add(value); } else { Right = Right ?? new BinaryTree <T>(); Right.Add(value); } tree.Add(value); }