Exemplo n.º 1
0
 private void Draw(BinarySearchTree binaryTree)
 {
     int[] array = new int[] { 55, 5, 88, 50, 25, 11, 26, 17, 70, 99, 18, 78, 23,3,4};
     binaryTree.Init(array);
     int length = binaryTree.Height();
     int depth = (int)(Math.Pow(2, length - 1));
     int deltaY = (int)(this.Size.Height / (length + 1));
     int x = (int)(this.Size.Width / 2.0);
     bool[,] isUsed = new bool[length, depth];
     int[,] tree = new int[length, depth];
     binaryTree.ReturnTree(ref tree, ref isUsed);
     Graphics g = CreateGraphics();
     g.Clear(this.BackColor);
     int i = 0;
     BinarySearchTree.Node nowNode = binaryTree.treeRoot;
     GetTree(i, ref nowNode, length, g, deltaY, x, x);
 }
Exemplo n.º 2
0
 public void CountHeightTest(int[] mas, int res)
 {
     BinarySearchTree b = new BinarySearchTree();
     b.Init(mas);
     int nodes = b.Height();
     Assert.AreEqual(res, nodes);
 }