package tree.binarytree;
import java.util.LinkedList;
/**
* 层序遍历二叉树
*
* @author wl
*
*/
public class PrintFromTopToBotton {
public static void printfromtoptobotton(BiTreeNode root) {
if (root == null) {
return;
}
LinkedList queue = new LinkedList();
queue.addLast(root);
while (queue.size() != 0) {
BiTreeNode current = queue.pollFirst();
System.out.println(current.data);
if (current.leftNode != null) {
queue.addLast(current.leftNode);
}
if (current.rightNode != null) {
queue.addLast(current.rightNode);
}
}
}
}