Example #1
0
 public void SizeTest(int[] mas, int res)
 {
     BinarySearchTree b = new BinarySearchTree();
     b.Init(mas);
     int size = b.Size();
     Assert.AreEqual(res, size);
 }
Example #2
0
 public void ClearTest(int[] mas)
 {
     BinarySearchTree b = new BinarySearchTree();
     b.Init(mas);
     b.Clear();
     int size = b.Size();
     Assert.AreEqual(0, size);
 }
Example #3
0
 public void DelTest(int[] mas, int res, int[] expMas)
 {
     BinarySearchTree b = new BinarySearchTree();
     b.Init(mas);
     b.Del(11);
     int size = b.Size();
     Assert.AreEqual(res, size);
     int[] masRes = b.ToArray();
     CollectionAssert.AreEqual(expMas, masRes);
 }
Example #4
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);
 }
Example #5
0
 public void CountWidthTest(int[] mas, int res)
 {
     BinarySearchTree b = new BinarySearchTree();
     b.Init(mas);
     int nodes = b.Width();
     Assert.AreEqual(res, nodes);
 }
Example #6
0
 public void ToStringTest(int[] mas, int[] expMas)
 {
     BinarySearchTree b = new BinarySearchTree();
     b.Init(mas);
     string masRes = b.TreeToString();
     CollectionAssert.AreEqual(expMas.ToString(), masRes);
 }