public void UnitTest()
 {
     string str = "4271369";
     BinaryTree bt = new BinaryTree(str);
     Console.WriteLine(MaxDepthByRecursive(bt.root));
     Console.WriteLine(MaxDepthByQueueAndDFS(bt.root));
 }
 public void UnitTest()
 {
     List<string> list = new List<string> { "", "1", "12", "123", "1234", "12345", "123456", "1234567", "1234567890123456789" };
     for (int index = 0; index < list.Count; index++)
     {
         string x = list[index];
         BinaryTree bt = new BinaryTree(list[index]);
         Console.WriteLine(CountNodes(bt.root));
     }
 }
        public void UnitTest()
        {
            string str = "4271369";
            BinaryTree bt = new BinaryTree(str);
            TreeNode node = InvertBinaryTreeByRecursion(bt.root);
            bt.PreOrder(node);
            Console.WriteLine();

            node = InvertBinaryTreeByNoRecursion(bt.root);
            bt.PreOrder(node);
        }
        public void UnitTest()
        {
            Console.WriteLine("IsValidBSTByRecursive");
            BinaryTree bt = new BinaryTree("4271369");
            Console.WriteLine(IsValidBSTByRecursive(bt.root));

            bt = new BinaryTree("4721369");
            Console.WriteLine(IsValidBSTByRecursive(bt.root));

            Console.WriteLine("IsValidBSTByNoRecursive");
            bt = new BinaryTree("4271369");
            Console.WriteLine(IsValidBSTByNoRecursive(bt.root));

            bt = new BinaryTree("4721369");
            Console.WriteLine(IsValidBSTByNoRecursive(bt.root));
        }
        public void UnitTest()
        {
            Console.WriteLine("PostorderTraversalByRecursive");
            BinaryTree bt = new BinaryTree("4271369");
            var list = PostorderTraversalByRecursive(bt.root);
            for (int index = 0; index < list.Count; index++)
                Console.Write(list[index] - 48);

            Console.WriteLine();

            Console.WriteLine("PostorderTraversalByNoRecursiveAndStack");
            bt = new BinaryTree("");
            list = PostorderTraversalByNoRecursiveAndStack(bt.root);
            for (int index = 0; index < list.Count; index++)
                Console.Write(list[index] - 48);
        }
        public void UnitTest()
        {
            string str = "4271369";
            BinaryTree bt = new BinaryTree(str);
            var list = InOrderTraversalByRecursive(bt.root);

            for (int index = 0; index < list.Count; index++)
                Console.Write((list[index] - 48) + "  ");

            Console.WriteLine();

            list = InOrderTraversalByNoRecursive(bt.root);
            for (int index = 0; index < list.Count; index++)
            {
                Console.Write((list[index] - 48) + "  ");
            }
            Console.WriteLine();
        }