@@ -0,0 +1,1330 @@
+package careerCup;%0D%0A%0D%0A/*%0D%0A * Link: http://www.careercup.com/question?id=83696%0D%0A * Write code to print out a binary tree so that each depth is printed on its own line.%0D%0A * The spacing doesn't need to be correct, but the items within a depth must be in order and on a single line.%0D%0A *         1%0D%0A *       /   %5C%0D%0A *     2       3%0D%0A *            / %5C%0D%0A *           4   5%0D%0A *                %5C %0D%0A *                 7%0D%0A * 1%0D%0A * 2 3%0D%0A * 4 5%0D%0A * 7%0D%0A */%0D%0Apublic class _16googleCareerCup %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09TreeNode tn=new TreeNode(1);%0D%0A%09%09tn.left=new TreeNode(2);%0D%0A%09%09tn.right=new TreeNode(3);%0D%0A%09%09tn.right.left=new TreeNode(4);%0D%0A%09%09tn.right.right=new TreeNode(5);%0D%0A%09%09tn.right.right.right=new TreeNode(7);%0D%0A%09%09int height=getHeight(tn);%0D%0A%09%09for (int i = 0; i %3C=height; i++) %7B%0D%0A%09%09%09printElements(tn,i);%0D%0A%09%09%09System.out.println();%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09private static void printElements(TreeNode tn,int i) %7B%0D%0A%09%09if(tn!=null)%0D%0A%09%09%7B%0D%0A%09%09%09if(i==1)%0D%0A%09%09%09%09System.out.print(tn.val);%0D%0A%09%09%09printElements(tn.left, i-1);%0D%0A%09%09%09printElements(tn.right, i-1);%09%09%09%0D%0A%09%09%7D%0D%0A%09%7D%0D%0A%09private static int getHeight(TreeNode tn) %7B%0D%0A%09%09if(tn!=null)%0D%0A%09%09%7B%0D%0A%09%09%09return 1+Math.max(getHeight(tn.left),getHeight(tn.right));%0D%0A%09%09%7D%0D%0A%09%09return 0;%0D%0A%09%7D%0D%0A%09static class TreeNode%7B%0D%0A%09%09TreeNode left,right;%0D%0A%09%09int val;%0D%0A%09%09public TreeNode(int val) %7B%0D%0A%09%09%09this.val=val;%0D%0A%09%09%7D%0D%0A%0D%0A%0D%0A%09%7D%0D%0A%0D%0A%7D%0D%0A

print level by level completed