@@ -0,0 +1,1101 @@
+// Java program for preorder tree traversals%0A%0A/* Class containing left and right child of current%0Anode and key value*/%0Aclass Node %7B%0A%09int key;%0A%09Node left, right;%0A%0A%09public Node(int item)%0A%09%7B%0A%09%09key = item;%0A%09%09left = right = null;%0A%09%7D%0A%7D%0A%0Aclass BinaryTree %7B%0A%09// Root of Binary Tree%0A%09Node root;%0A%0A%09BinaryTree() %7B root = null; %7D%0A%0A%09/* Given a binary tree, print its nodes in preorder*/%0A%09void printPreorder(Node node)%0A%09%7B%0A%09%09if (node == null)%0A%09%09%09return;%0A%0A%09%09/* first print data of node */%0A%09%09System.out.print(node.key + %22 %22);%0A%0A%09%09/* then recur on left subtree */%0A%09%09printPreorder(node.left);%0A%0A%09%09/* now recur on right subtree */%0A%09%09printPreorder(node.right);%0A%09%7D%0A%0A%09// Wrappers over the above recursive function%0A%09void printPreorder() %7B printPreorder(root); %7D%0A%0A%09// Driver method%0A%09public static void main(String%5B%5D args)%0A%09%7B%0A%09%09BinaryTree tree = new BinaryTree();%0A%09%09tree.root = new Node(1);%0A%09%09tree.root.left = new Node(2);%0A%09%09tree.root.right = new Node(3);%0A%09%09tree.root.left.left = new Node(4);%0A%09%09tree.root.left.right = new Node(5);%0A%0A%09%09System.out.println(%0A%09%09%09%22Preorder traversal of binary tree is %22);%0A%09%09tree.printPreorder();%0A%09%7D%0A%7D%0A%0A

Create preorder_traversal.java