从上往下按层打印树的每个结点

public static void printTreeFromBttom(MyNode node){
    	Queue<MyNode> queue = new LinkedList<MyNode>();
    	queue.add(node);
    	while(!queue.isEmpty()){
    		MyNode nodeTmp = queue.poll();
    		System.out.println(nodeTmp.data);
    		if(nodeTmp.left != null){
    		    queue.add(nodeTmp.left);
    		}
    		
    		if(nodeTmp.right != null){
    			queue.add(nodeTmp.right);
    		}
    	}
    }



你可能感兴趣的:(从上往下按层打印树的每个结点)