Example #1
0
        //data: 8>4>11>3; 8>5>9; 5>7>1; 7>12>2
        public BTree GetUnbalancedTree()
        {
            BTree tree = new BTree();
            tree.Root = new BNode(8);

            tree.Root.Left = new BNode(5);

            tree.Root.Left.Left = new BNode(9);
            tree.Root.Left.Right = new BNode(7);
            tree.Root.Left.Right.Left = new BNode(1);
            tree.Root.Left.Right.Right = new BNode(12);
            tree.Root.Left.Right.Right.Left = new BNode(2);

            tree.Root.Right = new BNode(4);
            tree.Root.Right.Right = new BNode(11);
            tree.Root.Right.Right.Left = new BNode(3);

            return tree;
        }
Example #2
0
 public bool CheckBalanced(BTree tree)
 {
     bool result = true;
     int maxDepth = GetMaxDepth(tree.Root, ref result);
     return result;
 }