public void InternalSearchRootNullTest_notfound()
        {
            var t = new ImprovedBinSearchTree();

            var(pre, node, direction, found) = t.DetailedSearch(5);

            Assert.IsNull(pre);
            Assert.IsNull(node);
            Assert.AreEqual(BinSearchTree.Direction.Unset, direction);
            Assert.IsFalse(found);
        }
        public void InternalSearchRootTest_notfound()
        {
            var       t     = new ImprovedBinSearchTree();
            const int value = 5;

            t.Insert(4);

            var(pre, node, direction, found) = t.DetailedSearch(value);

            Assert.AreEqual(4, pre.Value);
            Assert.IsNull(node);
            Assert.AreEqual(BinSearchTree.Direction.Right, direction);
            Assert.IsFalse(found);
        }
        public void InternalSearchRootTest_found()
        {
            var       t     = new ImprovedBinSearchTree();
            const int value = 5;

            t.Insert(value);

            var(pre, node, direction, found) = t.DetailedSearch(value);

            Assert.IsNull(pre);
            Assert.AreEqual(value, node.Value);
            Assert.AreEqual(BinSearchTree.Direction.Unset, direction);
            Assert.IsTrue(found);
        }
        public void DeleteTest_SymmetricPredecessorIsChild_EzTree_CheckForPredecessors()
        {
            var t = new ImprovedBinSearchTree();

            t.Insert(10);
            t.Insert(5);
            t.Insert(6);
            t.Insert(4);
            Console.WriteLine("Bevor delete");
            t.Print();
            var deleted = t.Delete(5);

            Console.WriteLine("After delete");
            t.Print();
            Assert.IsTrue(deleted);
            var(pre6, node6, _, _) = t.DetailedSearch(6);
            var(pre4, node4, _, _) = t.DetailedSearch(4);

            Assert.AreEqual(pre6.Value, ((DoubleLinkBinSearchTreeNode)node6).Previous.Value);
            Assert.AreEqual(4, ((DoubleLinkBinSearchTreeNode)node6).Previous.Value);
            Assert.AreEqual(10, ((DoubleLinkBinSearchTreeNode)node4).Previous.Value);
            Assert.AreEqual(pre4.Value, ((DoubleLinkBinSearchTreeNode)node4).Previous.Value);
        }
        public void DeleteTest_SymmetricPredecessorIsChild_HiddenSymPre_CheckForPredecessors()
        {
            var t = new ImprovedBinSearchTree();

            t.Insert(45);
            t.Insert(18);
            t.Insert(67);
            t.Insert(10);
            t.Insert(41);
            t.Insert(56);
            t.Insert(97);
            t.Insert(43);
            t.Insert(66);
            t.Insert(95);
            t.Insert(59);
            t.Insert(57);
            t.Insert(64);
            Console.WriteLine("Bevor delete");
            t.Print();

            t.Delete(67);

            Console.WriteLine("After delete");
            t.Print();
            var(pre66, node66, _, _) = t.DetailedSearch(66);
            var(pre56, node56, _, _) = t.DetailedSearch(56);
            var(pre97, node97, _, _) = t.DetailedSearch(97);


            Assert.AreEqual(pre66.Value, ((DoubleLinkBinSearchTreeNode)node66).Previous.Value);
            Assert.AreEqual(45, ((DoubleLinkBinSearchTreeNode)node66).Previous.Value);
            Assert.AreEqual(pre56.Value, ((DoubleLinkBinSearchTreeNode)node56).Previous.Value);
            Assert.AreEqual(66, ((DoubleLinkBinSearchTreeNode)node56).Previous.Value);
            Assert.AreEqual(pre97.Value, ((DoubleLinkBinSearchTreeNode)node97).Previous.Value);
            Assert.AreEqual(66, ((DoubleLinkBinSearchTreeNode)node97).Previous.Value);
        }