public void AddKeyValue()
        {
            // adding to ZeroTree
            Assert.AreEqual(0, ZeroTree.Count());
            ZeroTree.AddKeyValue(150, 150);
            ZeroTree.AddKeyValue(10, 10);
            ZeroTree.AddKeyValue(30, 30);
            Assert.AreEqual(3, ZeroTree.Count());

            // adding the same values
            Assert.AreEqual(9, Tree.Count());
            Tree.AddKeyValue(150, 150);
            Tree.AddKeyValue(10, 10);
            Tree.AddKeyValue(30, 30);
            Assert.AreEqual(9, Tree.Count());

            Assert.AreEqual(false, Tree.FindNodeByKey(-50).NodeHasKey);
            Assert.AreEqual(false, Tree.FindNodeByKey(35).NodeHasKey);
            Assert.AreEqual(false, Tree.FindNodeByKey(160).NodeHasKey);

            // adding the new values
            Tree.AddKeyValue(-50, -50);
            Tree.AddKeyValue(35, 35);
            Tree.AddKeyValue(160, 160);
            Assert.AreEqual(12, Tree.Count());

            Assert.AreEqual(true, Tree.FindNodeByKey(-50).NodeHasKey);
            Assert.AreEqual(true, Tree.FindNodeByKey(35).NodeHasKey);
            Assert.AreEqual(true, Tree.FindNodeByKey(160).NodeHasKey);
        }
        public void TestInitialize()
        {
            ZeroTree = new BST <int>(null);
            Tree     = new BST <int>(null);

            Tree.AddKeyValue(50, 50);
            Tree.AddKeyValue(100, 100);
            Tree.AddKeyValue(25, 25);
            Tree.AddKeyValue(150, 150);
            Tree.AddKeyValue(10, 10);
            Tree.AddKeyValue(30, 30);
            Tree.AddKeyValue(80, 80);
            Tree.AddKeyValue(75, 75);
            Tree.AddKeyValue(79, 79);
        }
        public void DeepAllNodes()
        {
            BST <int> BSTTree = new BST <int>(null);

            Assert.AreEqual(0, BSTTree.Count());

            BSTTree.AddKeyValue(50, 50);
            BSTTree.AddKeyValue(25, 25);
            BSTTree.AddKeyValue(10, 10);
            BSTTree.AddKeyValue(-50, -50);
            BSTTree.AddKeyValue(30, 30);
            BSTTree.AddKeyValue(35, 35);
            BSTTree.AddKeyValue(100, 100);
            BSTTree.AddKeyValue(80, 80);
            BSTTree.AddKeyValue(75, 75);
            BSTTree.AddKeyValue(79, 79);
            BSTTree.AddKeyValue(150, 150);
            BSTTree.AddKeyValue(160, 160);

            Assert.AreEqual(12, BSTTree.Count());

            /*                [50]
             *        (25)               (100)
             *     (10)  (30)        (80)     (150)
             *   (-50)     (35)  (75)            (160)
             *                      (79)
             */

            // in-order (0)
            List <BSTNode <int> > DeepNodes0 = BSTTree.DeepAllNodes(0);
            string order0 = "";

            for (int i = 0; i < DeepNodes0.Count; i++)
            {
                order0 = order0 + DeepNodes0[i].NodeKey.ToString() + " ";
            }

            Assert.AreEqual("-50 10 25 30 35 50 75 79 80 100 150 160 ", order0);

            // post-order (1)
            List <BSTNode <int> > DeepNodes1 = BSTTree.DeepAllNodes(1);
            string order1 = "";

            for (int i = 0; i < DeepNodes1.Count; i++)
            {
                order1 = order1 + DeepNodes1[i].NodeKey.ToString() + " ";
            }

            Assert.AreEqual("-50 10 35 30 25 79 75 80 160 150 100 50 ", order1);

            // pre-order (2)
            List <BSTNode <int> > DeepNodes2 = BSTTree.DeepAllNodes(2);
            string order2 = "";

            for (int i = 0; i < DeepNodes2.Count; i++)
            {
                order2 = order2 + DeepNodes2[i].NodeKey.ToString() + " ";
            }

            Assert.AreEqual("50 25 10 -50 30 35 100 80 75 79 150 160 ", order2);
        }
        public void WideAllNodes()
        {
            BST <int> BSTTree = new BST <int>(null);

            Assert.AreEqual(0, BSTTree.Count());

            BSTTree.AddKeyValue(50, 50);
            BSTTree.AddKeyValue(25, 25);
            BSTTree.AddKeyValue(10, 10);
            BSTTree.AddKeyValue(-50, -50);
            BSTTree.AddKeyValue(30, 30);
            BSTTree.AddKeyValue(35, 35);
            BSTTree.AddKeyValue(100, 100);
            BSTTree.AddKeyValue(80, 80);
            BSTTree.AddKeyValue(75, 75);
            BSTTree.AddKeyValue(79, 79);
            BSTTree.AddKeyValue(150, 150);
            BSTTree.AddKeyValue(160, 160);

            Assert.AreEqual(12, BSTTree.Count());

            /*                [50]
             *        (25)               (100)
             *     (10)  (30)        (80)     (150)
             *   (-50)     (35)  (75)            (160)
             *                      (79)
             */

            List <BSTNode <int> > WideNodes = BSTTree.WideAllNodes();
            string wideResult = "";

            for (int i = 0; i < WideNodes.Count; i++)
            {
                wideResult = wideResult + WideNodes[i].NodeKey.ToString() + " ";
            }

            Assert.AreEqual("50 25 100 10 30 80 150 -50 35 75 160 79 ", wideResult);
        }