static void Main(string[] args) { var tree = new BinaryTree <double>(); tree.Insert(50); tree.Insert(30); tree.Insert(60); tree.Insert(25); tree.Insert(31); tree.Insert(29); tree.Insert(32); tree.GetBalance(); Console.WriteLine(tree.Head.Value); }
static void Main(string[] args) { BinaryTree tree = new BinaryTree(); string result; do { Console.WriteLine("1. Insert"); Console.WriteLine("2. Search"); Console.WriteLine("3. Remove"); Console.WriteLine("4. Print"); Console.WriteLine("5. PreOrderPrint"); Console.WriteLine("6. InOrderPrint"); Console.WriteLine("7. PostOrderPrint"); Console.WriteLine("8. Exit"); result = Console.ReadLine(); if (result == "1") { Console.WriteLine("what do you want to insert?"); char inserted = char.Parse(Console.ReadLine()); tree.Insert(inserted); Console.WriteLine(); } if (result == "2") { Console.WriteLine("What letter do you want to search for?"); char Searched = char.Parse(Console.ReadLine()); if (tree.Search(Searched) == false) { Console.WriteLine("Sorry, the letter doesn't exist."); Console.WriteLine(); } if (tree.Search(Searched) == true) { Console.WriteLine("Yay, " + Searched + " exists!"); Console.WriteLine(); } tree.Search(Searched); } if (result == "3") { Console.WriteLine("What letter do you want to remove?"); tree.Remove(char.Parse(Console.ReadLine())); Console.WriteLine(); } if (result == "4") { tree.Print(); } if (result == "5") { tree.PreOrderPrint(); Console.WriteLine(); Console.WriteLine(); } if (result == "6") { tree.InOrderPrint(); Console.WriteLine(); Console.WriteLine(); } if (result == "7") { tree.PostOrderPrint(); Console.WriteLine(); Console.WriteLine(); } } while (result != "8"); }
static void Main(string[] args) { BinaryTree <int> binaryTree = new BinaryTree <int>(); binaryTree.Insert(60); binaryTree.Insert(35); binaryTree.Insert(76); binaryTree.Insert(42); binaryTree.Insert(17); binaryTree.Insert(68); binaryTree.Insert(11); binaryTree.Insert(24); binaryTree.Insert(63); binaryTree.Insert(69); binaryTree.Insert(23); binaryTree.Delete(35); binaryTree.InOrder(binaryTree.Root); //binaryTree.Insert(50); //binaryTree.Insert(75); //binaryTree.Insert(93); //binaryTree.Insert(87); //binaryTree.Insert(62); //binaryTree.Delete(75); //binaryTree.InOrder(binaryTree.Root); Console.ReadKey(); }