Exemplo n.º 1
0
        public void DeleteLeaf_tree_Culled()
        {
            var root = new SortedTree <int>(60);

            root.Add(35);
            root.Add(76);
            root.Add(21);
            root.Add(42);
            root.Add(71);
            root.Add(89);
            root.Add(17);
            root.Add(24);
            root.Add(68);
            root.Add(11);
            root.Add(23);
            root.Add(63);
            root.Add(69);

            root.Delete(89);

            var tree = root.DepthFirst().ToArray();

            Assert.AreEqual(
                new int[] { 60, 35, 76, 21, 42, 71, 17, 24, 68, 11, 23, 63, 69 },
                tree);
        }
Exemplo n.º 2
0
        public void DeleteLeafWithRightChild_tree_Culled()
        {
            var root = new SortedTree <int>(60);

            root.Add(35);
            root.Add(76);
            root.Add(80);
            root.Add(82);

            root.Delete(80);

            var tree = root.DepthFirst().ToArray();

            Assert.AreEqual(
                new int[] { 60, 35, 76, 82 },
                tree);
        }
Exemplo n.º 3
0
        public void DeleteLeafWithTwoChildrenLCaseTwoB_tree_Culled()
        {
            var root = new SortedTree <int>(60);

            root.Add(35);
            root.Add(76);
            root.Add(17);
            root.Add(42);
            root.Add(68);
            root.Add(11);
            root.Add(24);
            root.Add(63);
            root.Add(69);

            root.Delete(35);

            var tree = root.DepthFirst().ToArray();

            Assert.AreEqual(
                new int[] { 60, 24, 76, 17, 42, 68, 11, 63, 69 },
                tree);
        }