public void AssertValidTree_InvalidChildren()
        {
            var root = new RedBlackNode <int>(100);

            root.Left = new RedBlackNode <int>(150);

            RedBlackTree <int> bst = new RedBlackTree <int>();

            bst.Root = root;

            bst.AssertValidTree();
        }
Example #2
0
        public void AssertValidTree_InvalidChildren()
        {
            var root = new RedBlackNode <int>(100)
            {
                Left = new RedBlackNode <int>(150)
            };

            var bst = new RedBlackTree <int> {
                Root = root
            };

            bst.AssertValidTree();
        }
        public void AssertValidTree_Invalid_BlackMismatch_Right()
        {
            RedBlackNode <int> root = new RedBlackNode <int>(100, Colour.Black);

            root.Left        = new RedBlackNode <int>(50, Colour.Red);
            root.Right       = new RedBlackNode <int>(150, Colour.Red);
            root.Right.Right = new RedBlackNode <int>(160, Colour.Red);

            RedBlackTree <int> bst = new RedBlackTree <int>();

            bst.Root = root;

            bst.AssertValidTree();
        }
        public void AssertValidTree_Invalid_DoubleRed_Left()
        {
            RedBlackNode <int> root = new RedBlackNode <int>(100, Colour.Black);

            root.Left      = new RedBlackNode <int>(50, Colour.Red);
            root.Right     = new RedBlackNode <int>(150, Colour.Red);
            root.Left.Left = new RedBlackNode <int>(40, Colour.Red);

            RedBlackTree <int> bst = new RedBlackTree <int>();

            bst.Root = root;

            bst.AssertValidTree();
        }
Example #5
0
        public void AssertValidTree_Invalid_BlackMismatch_Left()
        {
            var root = new RedBlackNode <int>(100, Color.Black)
            {
                Left  = new RedBlackNode <int>(50, Color.Red),
                Right = new RedBlackNode <int>(150, Color.Red)
            };

            root.Left.Left = new RedBlackNode <int>(40, Color.Red);

            var bst = new RedBlackTree <int> {
                Root = root
            };

            bst.AssertValidTree();
        }
Example #6
0
        public void AssertValidTree_Invalid_DoubleRed_Right()
        {
            var root = new RedBlackNode <int>(100, Color.Black)
            {
                Left  = new RedBlackNode <int>(50, Color.Red),
                Right = new RedBlackNode <int>(150, Color.Red)
                {
                    Right = new RedBlackNode <int>(160, Color.Red)
                }
            };

            var bst = new RedBlackTree <int> {
                Root = root
            };

            bst.AssertValidTree();
        }
        public void AssertValidTree_InvalidChildren()
        {
            var root = new RedBlackNode<int>(100);
            root.Left = new RedBlackNode<int>(150);

            RedBlackTree<int> bst = new RedBlackTree<int>();
            bst.Root = root;

            bst.AssertValidTree();
        }
        public void AssertValidTree_Invalid_DoubleRed_Right()
        {
            RedBlackNode<int> root = new RedBlackNode<int>(100, Colour.Black);
            root.Left = new RedBlackNode<int>(50, Colour.Red);
            root.Right = new RedBlackNode<int>(150, Colour.Red);
            root.Right.Right = new RedBlackNode<int>(160, Colour.Red);

            RedBlackTree<int> bst = new RedBlackTree<int>();
            bst.Root = root;

            bst.AssertValidTree();
        }
        public void AssertValidTree_Invalid_BlackMismatch_Left()
        {
            RedBlackNode<int> root = new RedBlackNode<int>(100, Colour.Black);
            root.Left = new RedBlackNode<int>(50, Colour.Red);
            root.Right = new RedBlackNode<int>(150, Colour.Red);
            root.Left.Left = new RedBlackNode<int>(40, Colour.Red);

            RedBlackTree<int> bst = new RedBlackTree<int>();
            bst.Root = root;

            bst.AssertValidTree();
        }