@@ -0,0 +1,1584 @@
+package algorithm;%0A%0A/**%0A * Created by yefeng on 16/11/28.%0A * %E8%BE%93%E5%85%A5%E4%B8%80%E9%A2%97%E4%BA%8C%E5%85%83%E6%A0%91,%E4%BB%8E%E4%B8%8A%E5%BE%80%E4%B8%8B%E6%8C%89%E5%B1%82%E6%89%93%E5%8D%B0%E6%A0%91%E7%9A%84%E6%AF%8F%E4%B8%AA%E7%BB%93%E7%82%B9,%E5%90%8C%E4%B8%80%E5%B1%82%E4%B8%AD%E6%8C%89%E7%85%A7%E4%BB%8E%E5%B7%A6%E5%BE%80%E5%8F%B3%E7%9A%84%E9%A1%BA%E5%BA%8F%E6%89%93%E5%8D%B0%E3%80%82%0A * %E4%BE%8B%E5%A6%82%E8%BE%93%E5%85%A5%0A *     8%0A *    / %5C%0A *   6  10%0A *  /%5C  /%5C%0A * 5 7 9 11%0A * %E8%BE%93%E5%87%BA 8 6 10 5 7 9 11%E3%80%82%0A */%0Apublic class PrintTree %7B%0A%0A    public static class Node %7B%0A        public Node(int value, Node left, Node right) %7B%0A            this.val_ = value;%0A            this.left_ = left;%0A            this.right_ = right;%0A        %7D%0A        int val_;%0A        Node left_;%0A        Node right_;%0A    %7D%0A%0A    public static void printTree(Node root, int level) %7B%0A        if (root != null) %7B%0A            System.out.println(root.val_ +%22@%22+ level);%0A            printTree(root.left_, level+1);%0A            printTree(root.right_, level+1);%0A        %7D%0A    %7D%0A%0A    private static java.util.Queue%3CNode%3E queue = new java.util.LinkedList%3CNode%3E();%0A%0A    public static void printTree2(Node root) %7B%0A        queue.add(root);%0A        Node tmp = null;%0A        while (!queue.isEmpty()) %7B%0A            tmp = queue.poll();%0A            if (tmp.left_ != null) queue.add(tmp.left_);%0A            if (tmp.right_ != null) queue.add(tmp.right_);%0A            System.out.println(tmp.val_);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Node n1 = new Node(5, null, null);%0A        Node n2 = new Node(7, null, null);%0A        Node n3 = new Node(9, null, null);%0A        Node n4 = new Node(11, null, null);%0A%0A        Node n5 = new Node(6, n1, n2);%0A        Node n6 = new Node(10, n3, n4);%0A%0A        Node n7 = new Node(8, n5, n6);%0A%0A        printTree(n7, 0);%0A%0A        System.out.println(%22----------%22);%0A%0A        printTree2(n7);%0A%0A    %7D%0A%7D%0A

add files