Пример #1
0
        private void dichotomyTree(AVL tree, int[] array, int start, int end)
        {
            double middle    = (end - start) / 2;
            int    rootIndex = (int)Math.Floor(middle);

            tree.Add(array[start + rootIndex]);
            if (end - start > 0)
            {
                if (start + rootIndex - 1 >= 0)
                {
                    dichotomyTree(tree, array, start, start + rootIndex - 1);
                }

                if (start + rootIndex + 1 >= 0 && end >= 0)
                {
                    dichotomyTree(tree, array, start + rootIndex + 1, end);
                }
            }
        }
Пример #2
0
        public static void Driver()
        {
            AVL avlTree = new AVL();

            for (int i = 1; i <= 40; i++)
            {
                avlTree.Add(i);
            }

            avlTree.DisplayTree();
            Console.WriteLine();

            avlTree.Delete(15);
            avlTree.DisplayTree();
            Console.WriteLine();

            avlTree.Delete(3);
            avlTree.DisplayTree();
            Console.WriteLine();
        }
 private bool isAVLTreeValid(AVL tree)
 {
     return(recursiveCheck(tree.Head()));
 }