public void InitialTreeHasDepthZero() { var myTree = new DemoTree <int>(); myTree.Add(1); Assert.AreEqual(0, myTree.Depth()); }
private DemoTree <int> CreateTreeWithValues(int numberOfValues) { if (numberOfValues <= 0) { return(null); } var tree = new DemoTree <int>(1); for (int i = 2; i <= numberOfValues; i++) { tree.Add(i); } return(tree); }
public void Add(T value) { if (LeftChild == null) { LeftChild = new DemoTree <T>(value); return; } if (RightChild == null) { RightChild = new DemoTree <T>(value); return; } if (LeftChild.Depth() <= RightChild.Depth()) { LeftChild.Add(value); return; } RightChild.Add(value); }