static void Main(string[] args) { BST tree = new BST(68); //testing for equal head // tree.Search(68); //testing for unequal to head // tree.Search(67); //testing add function tree.Add(11); tree.Add(50); tree.Add(25); tree.Add(61); tree.Add(200); tree.Add(69); tree.Add(210); tree.Add(211); //testing searches tree.Search(25); tree.Search(211); //testing failed searches tree.Search(70); tree.Search(0); Console.ReadKey(); }
static void Main(string[] args) { Tree root, temp; root = temp = null; Console.WriteLine("Create Tree:"); BST bst = new BST(); #region create tree bst.InsertChild(ref root, 9); bst.InsertChild(ref root, 4); bst.InsertChild(ref root, 15); bst.InsertChild(ref root, 6); bst.InsertChild(ref root, 12); bst.InsertChild(ref root, 17); bst.InsertChild(ref root, 2); #endregion #region print Console.WriteLine("Pre Order Display"); // actual tree bst.Print_Preorder(root); Console.WriteLine("In Order Display"); bst.Print_Inorder(root); Console.WriteLine("Post Order Display"); bst.Print_Postorder(root); #endregion #region searching int val = 15; temp = bst.Search(ref root, val); if (temp != null && bst.isFound) { Console.WriteLine("Searched node = {0}", val); } else { Console.WriteLine("Data not found in tree."); } #endregion #region delete bst.DeleteTree(ref root); #endregion Console.ReadLine(); }