static void Main(string[] args) { //declrations BinaryTree tree = new BinaryTree(); int choice = -1; // end of declarations // initialize data structures do { // display user menu Console.WriteLine(); Console.WriteLine("Please enter your choice:"); Console.WriteLine("0. Press O to exit"); Console.WriteLine("1. Create a new Tree"); Console.WriteLine("2. Add new nodes to Tree"); Console.WriteLine("3. Print Tree in Inorder"); Console.WriteLine("4. Print Tree in Preorder"); Console.WriteLine("5. Print Size of Tree"); Console.WriteLine("6. Print Depth of Tree"); Console.WriteLine("7. Print Tree"); Console.WriteLine("8. Print a Graph DFS"); Console.WriteLine("9. Print a Graph BFS"); Console.WriteLine("10. Check for Palindrome"); // get user choice try { choice = Int32.Parse((Console.ReadLine())); } catch (System.FormatException) { choice = -1; Console.WriteLine("Error!"); } // process user choice switch (choice) { case 0: Console.WriteLine("Goodbye..."); break; case 1: tree.CreateTree(); break; case 2: Console.WriteLine("What is the value of new Node?"); int i = Int32.Parse(Console.ReadLine()); Node newnode = new Node(i); tree.InsertNode(newnode); //tree.InsertNode(b); break; case 3: Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Inorder Traversal for the tree is:"); tree.PrintInorder(); Console.ResetColor(); break; case 4: Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Preorder Traversal for the trees is:"); tree.PrintPreorder(); Console.ResetColor(); break; case 5: Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Size of Tree is {0}", tree.size()); Console.ResetColor(); break; case 6: Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Depth of the Tree is {0}", tree.depth()); Console.ResetColor(); break; case 7: Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Printing the Tree"); tree.PrintTree(); Console.ResetColor(); break; case 8: //Console.BackgroundColor = ConsoleColor.Cyan; Console.ForegroundColor = ConsoleColor.Cyan; Graph g = CreateGraph(); PrintGraphDFS(g, 0); Console.ResetColor(); break; case 9: //Console.BackgroundColor = ConsoleColor.Cyan; Console.ForegroundColor = ConsoleColor.Cyan; g = CreateGraph(); PrintGraphBFS(g, 0); Console.ResetColor(); break; case 10: Console.ForegroundColor = ConsoleColor.Cyan; Console.WriteLine("Please enter the string to check: "); string str = Console.ReadLine(); Console.WriteLine(IsPalindrome(str.Trim())); Console.ResetColor(); break; default: Console.WriteLine("Invalid selection, please try again.."); break; } } while (choice != 0); }