예제 #1
0
        private void Rotale(IList <int> datas)
        {
            var tree = new RedBlackTree <int>();

            tree.Create(datas);

            foreach (var data in datas)
            {
                var node = tree.Search(tree.Root, data);
                if (!node.Right.IsEmpty())
                {
                    tree.LeftRotate(node);
                    tree.CheckNodeParent();
                }
            }

            foreach (var data in datas)
            {
                var node = tree.Search(tree.Root, data);
                if (!node.Left.IsEmpty())
                {
                    tree.RightRotate(node);
                }
                tree.CheckNodeParent();
            }
        }
예제 #2
0
 public static void CheckRedBlackTree(this RedBlackTree <int> tree)
 {
     CheckRoot(tree);
     CheckRedNode(tree);
     tree.CheckNodeParent();
 }