Ejemplo n.º 1
0
        public static void Main()
        {
            // Prompt user
            Console.WriteLine("Enter numbers between [0-100] that are separated by spaces:");

            // Takes user input
            string userInput;

            userInput = Console.ReadLine();

            // Parsing userInput into substrings
            string[] listOfStrings = userInput.Split(' ');

            // Instantiate the tree
            BinaryTree numTree = new BinaryTree();

            // Load the substrings into the tree
            foreach (var substring in listOfStrings)
            {
                numTree.TreeInsert(Convert.ToInt32(substring));
            }

            // Output to console
            Console.WriteLine("Your assorted string is: ");

            // Traverse the tree and print substrings in order
            numTree.InorderTraversal();

            // Print quantity of numbers in the tree
            Console.WriteLine("\nThe number of nodes in the tree is: " + numTree.TreeQuantity());

            // Print theoretical min number of levels in the tree
            Console.WriteLine("The theoretical minimum number of levels in the tree is: " + numTree.TheoreticalMinLevels());

            // Print actual number of levels in the tree
            Console.WriteLine("The actual number of levels in the tree is: " + numTree.ActualLevels());
        }