public static void Main() { int [] preorder = new int [] { 10, 9, 5, 4, 6, 7 }; int [] inorder = new int [] { 9, 10, 4, 5, 6, 7 }; BinaryTree bt = new BinaryTree(); Node root = bt.ConstructTree(preorder, inorder, 0, preorder.Length - 1, 0, inorder.Length - 1); System.Console.Write("Inorder traversal :"); bt.inorderTraversal(root); System.Console.Write("\nPreorder traversal :"); bt.preorderTraversal(root); System.Console.Write("\nPostorder traversal :"); bt.postorderTraversal(root); }
public static void Main() { int [] postorder = new int [] { 8, 6, 9, 7, 11, 4, 10 }; int [] inorder = new int [] { 8, 9, 6, 10, 7, 4, 11 }; BinaryTree bt = new BinaryTree(); Node root = bt.ConstructTree(inorder, postorder, 0, inorder.Length - 1, 0, postorder.Length - 1); System.Console.Write("Inorder traversal :"); bt.inorderTraversal(root); System.Console.Write("\nPreorder traversal :"); bt.preorderTraversal(root); System.Console.Write("\nPostorder traversal :"); bt.postorderTraversal(root); }