Exemplo n.º 1
0
        public void Run()
        {
            // Copying run setup code from previous problem to create tree
            int[]       sortedArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
            MinimalTree minimalTree = new MinimalTree();
            TreeNode    rootNode    = minimalTree.CreateMinimalBST(sortedArray);

            ListOfDepths lstOfDepths = new ListOfDepths();
            List <LinkedList <TreeNode> > listOfLinkedList = lstOfDepths.CreateLevelLinkedListNonRecursive(rootNode);

            List <LinkedList <TreeNode> > listOfLinkedListRecursive = lstOfDepths.CreateLevelLinkedListRecursive(rootNode);
        }
Exemplo n.º 2
0
        public void Run()
        {
            // Copying run setup code from previous problem to create tree
            int[]       sortedArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
            MinimalTree minimalTree = new MinimalTree();
            TreeNode    rootNode    = minimalTree.CreateMinimalBST(sortedArray);

            CheckBalanced checkBalanced = new CheckBalanced();

            Console.WriteLine("Is Balanced: " + checkBalanced.IsBalanced(rootNode));

            CheckBalancedV2 checkBalancedV2 = new CheckBalancedV2();

            Console.WriteLine("Is Balanced: " + checkBalancedV2.IsBalanced(rootNode));
        }
Exemplo n.º 3
0
        public void Run()
        {
            // Tree setup
            // Copying run setup code from previous problem to create tree
            int[]       sortedArray = new int[] { 1, 2, 3, 4, 5, 6, 7, 8 };
            MinimalTree minimalTree = new MinimalTree();
            TreeNode    rootNode    = minimalTree.CreateMinimalBST(sortedArray);

            ValidateBST validateBST = new ValidateBST();
            bool        isBST       = validateBST.CheckBSTApproach1(rootNode, sortedArray.Length);

            Console.WriteLine("Is BST using Approach 1:" + isBST);

            isBST = validateBST.CheckBSTApproach2(rootNode);
            Console.WriteLine("Is BST using Approach 2:" + isBST);

            isBST = validateBST.CheckBSTApproach3(rootNode);
            Console.WriteLine("Is BST using Approach 3:" + isBST);
        }