public void BinaryTree_RemoveTest() { var tree = new AVLBinaryTree <int>(); for (var i = 0; i < 10; i++) { tree.Add(i); } tree.Remove(5); CollectionAssert.AreEqual(tree.Inorder() .ToArray(), new[] { 0, 1, 2, 3, 4, 6, 7, 8, 9 }); }
public void BinaryTreeMergeTime_1000_Test() { var list = new List <int>(); var firstTree = new AVLBinaryTree <int>(); for (var i = 0; i < 500; i++) { firstTree.Add(i); list.Add(i); } var secondTree = new AVLBinaryTree <int>(); for (var i = 500; i < 1000; i++) { firstTree.Add(i); list.Add(i); } firstTree.MergeWith(secondTree); CollectionAssert.AreEqual(list, firstTree.Inorder() .ToArray()); }
public void BinaryTreeMerge_random_Test() { var list = new List <int>(); var rnd = new Random(); var firstTree = new AVLBinaryTree <int>(); for (var i = 0; i < 500; i++) { var num = rnd.Next(-50, 50); firstTree.Add(num); list.Add(num); } var secondTree = new AVLBinaryTree <int>(); for (var i = 500; i < 1000; i++) { var num = rnd.Next(-50, 50); firstTree.Add(num); list.Add(num); } firstTree.MergeWith(secondTree); list = list.Distinct() .ToList(); list.Sort(); CollectionAssert.AreEqual(list, firstTree.Inorder() .ToArray()); }
public void BinaryTreeMergeTest() { var firstTree = new AVLBinaryTree <int>(); for (var i = 0; i < 10; i++) { firstTree.Add(i); } var secondTree = new AVLBinaryTree <int>(); for (var i = 10; i < 20; i++) { firstTree.Add(i); } firstTree.MergeWith(secondTree); var checkArray = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; CollectionAssert.AreEqual(checkArray, firstTree.Inorder() .ToArray()); }
public void BinaryTree_Inorder_10000_test() { var rnd = new Random(); var numbers = Enumerable.Range(0, 10000) .Select(x => rnd.Next(-30, 30)) .Distinct() .ToArray(); var tree = new AVLBinaryTree <int>(numbers); var sortedNumbers = numbers.ToList(); sortedNumbers.Sort(); var inorder = tree.Inorder() .ToArray(); CollectionAssert.AreEqual(inorder, sortedNumbers); }
public void AVLBinaryTreeInorder() => _avl.Inorder();