static void Main(string[] args) { TreeNode node = new TreeNode(4); node.left = new TreeNode(1); node.left.left = new TreeNode(0); node.left.right = new TreeNode(2); node.left.right.right = new TreeNode(3); node.right = new TreeNode(6); node.right.left = new TreeNode(5); node.right.right = new TreeNode(7); node.right.right.right = new TreeNode(8); //node.right.right.right = new TreeNode(1); BinaryTree tree = new BinaryTree(); #region Tree TreeNode inserBst = new TreeNode(4); inserBst.left = new TreeNode(2); inserBst.right = new TreeNode(7); inserBst.left.left = new TreeNode(1); inserBst.left.right = new TreeNode(3); tree.InsertIntoBST(inserBst, 5); tree.PrintTreelevelOrderRecursion(node); tree.PrintTreeLevelOrder(node); tree.BstToGst(node); tree.PrintTreeLevelOrder(tree.BstToGst(node)); #region BST to Greater Tree #endregion //Node node = new Node(6); //node.left = new Node(3); //node.left.left = new Node(2); //node.left.right = new Node(5); //node.left.right.right = new Node(4); //node.left.right.left = new Node(7); //node.right = new Node(5); //node.right.right = new Node(4); //TreeNode node = new TreeNode(5); //node.left = new TreeNode(4); //node.left.left = new TreeNode(11); //node.left.left.left = new TreeNode(7); //node.left.left.right = new TreeNode(2); //node.right = new TreeNode(8); //node.right.left = new TreeNode(13); //node.right.right = new TreeNode(4); //node.right.right.left = new TreeNode(5); //node.right.right.right = new TreeNode(1); //tree.PathSum(node, 22); //var list = tree.ZigzagLevelOrder(node); //Node ancestor = tree.LowestCommonAncestor(node, new Node(2), new Node(5)); //int sum = tree.TreePathSum(node); //bool isTrue = tree.TreePathSum(node,653); //bool isTrue = tree.IsBST(node); int height = tree.TreeHeight(node); tree.PrintTreePreOrder(node); tree.PrintTreePreOrderIterative(node); string serializedTree = tree.Serialize(node); tree.Deserialize(serializedTree); tree.PrintTreePreOrder(tree.Deserialize(serializedTree)); //string serializedTree = tree.Serialize(node, string.Empty); #endregion }