Example #1
0
        public void TestTreeToString()
        {
            KevinBst <string> testTree = BuildTestTree();
            IVisitor <string> visitor  = new StringBuilderVisitor();

            testTree.TraverseInOrder(visitor);
            Console.WriteLine(visitor.ToString());
        }
Example #2
0
        public void RemoveRightChildLeafNode()
        {
            KevinBst <string> testTree = BuildTestTree();

            testTree.Remove(key: 15);
            IVisitor <string> visitor = new StringBuilderVisitor();

            testTree.TraverseInOrder(visitor);
            Console.WriteLine(visitor.ToString());
        }
Example #3
0
        public void RemoveLeftChildOnlyHasLeftChild()
        {
            KevinBst <string> testTree = BuildTestTree();

            testTree.Remove(key: 15);
            // now 10 only has left child 5
            testTree.Remove(key: 10);
            IVisitor <string> visitor = new StringBuilderVisitor();

            testTree.TraverseInOrder(visitor);
            Console.WriteLine(visitor.ToString());
        }
Example #4
0
        public void RemoveRightChildOnlyHasRightChild()
        {
            KevinBst <string> testTree = BuildTestTree();

            testTree.Remove(key: 25);
            // now 30 only has right child 35
            testTree.Remove(key: 30);
            IVisitor <string> visitor = new StringBuilderVisitor();

            testTree.TraverseInOrder(visitor);
            Console.WriteLine(visitor.ToString());
        }