static void Main(string[] args) { Tree myTree = new Tree(); myTree.Add(100); myTree.Add(82); myTree.Add(78); myTree.Add(93); myTree.Add(116); myTree.Add(105); myTree.Add(123); myTree.Display(); Console.ReadLine(); Console.WriteLine("Pre-order: "); myTree.PreOrder(); Console.WriteLine(""); Console.WriteLine("In-order: "); myTree.InOrder(); Console.WriteLine(); Console.WriteLine("Post-order: "); myTree.PostOrder(); Console.WriteLine(); Console.WriteLine("Level order: "); myTree.LevelOrder(); Console.WriteLine(); Console.WriteLine(); myTree.Search(93); myTree.Search(100); myTree.Search(116); }
static void Main(string[] args) { Console.WriteLine("Binary Search Tree"); Tree <int> binarySearch = new Tree <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(67, binarySearch); Console.WriteLine(result); }