Exemple #1
0
        static void MakeTree()
        {
            List <int>    inputList = new List <int>();
            List <string> pathList  = new List <string>();

            BTree myTree = new BTree();

            inputList = Interface.Input("Input", "Geben Sie Zahlen ein die Sie zum Binary Tree hinzufügen wollen");

            foreach (var item in inputList)
            {
                myTree.Insert(item);
            }

            //Wert Finden
            inputList = Interface.Input("Werte Finden", "Geben Sie Zahlen ein die Sie im Binary Tree suchen wollen");
            foreach (var item in inputList)
            {
                myTree.Find(item);
                if (BTree.foundValue == true)
                {
                    pathList.Add(BTree.path);
                }
                else
                {
                    pathList.Add("Wert wurde nicht gefunden");
                }

                BTree.path = "";
            }

            Interface.PrintList(pathList, inputList);
        }
Exemple #2
0
        static void ExampleTree()
        {
            List <int>    inputList = new List <int>();
            List <string> pathList  = new List <string>();

            BTree myTree = new BTree();

            inputList.Add(10);
            inputList.Add(5);
            inputList.Add(2);
            inputList.Add(3);
            inputList.Add(8);
            inputList.Add(6);
            inputList.Add(9);
            inputList.Add(18);
            inputList.Add(17);
            inputList.Add(23);
            inputList.Add(40);

            Console.WriteLine();

            Interface.PrintList(inputList);
            foreach (var item in inputList)
            {
                myTree.Insert(item);
            }

            foreach (var item in inputList)
            {
                myTree.Find(item);
                if (BTree.foundValue == true)
                {
                    pathList.Add(BTree.path);
                }
                BTree.path = "";
            }

            Interface.PrintList(pathList, inputList);
        }