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); }
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); }
static void Main(string[] args) { Console.WriteLine("Welcome to Binary Search Tree"); BTree <int> binarySearch = new BTree <int>(56); binarySearch.Insert(30); binarySearch.Insert(70); binarySearch.Insert(22); binarySearch.Insert(40); binarySearch.Insert(60); binarySearch.Insert(95); binarySearch.Insert(11); binarySearch.Insert(65); binarySearch.Insert(3); binarySearch.Insert(16); binarySearch.Insert(63); binarySearch.Insert(67); binarySearch.Display(); binarySearch.GetSize(); bool result = binarySearch.IfExists(63, binarySearch); Console.WriteLine(result); }