// Creates a full binary tree. Each node is labelled with a string of // L's and R's, indicating the path from the root. The depth is specified // on the command line public class TestBinaryTree { public static void main(String[] args) { int depth = Integer.parseInt(args[0]); BinaryTree tree = BuildTree(depth,"#"); System.out.println("************ PREORDER *************"); tree.displayPreorder(); System.out.println("\n************ POSTORDER *************"); tree.displayPostorder(); System.out.println("\n************ INORDER *************"); tree.displayInorder(); } private static BinaryTree BuildTree(int depth, String path) { if (depth < 0) return null; BinaryTree N = new BinaryTree(path); N.setLeft(BuildTree(depth-1,path+"L")); N.setRight(BuildTree(depth-1,path+"R")); return N; } }