/**
* 二叉树的广度优先遍历
* @param root
* @return
*/
public List bfs(Node root) {
Queue queue = new LinkedList();
List list=new LinkedList();
if(root==null)
return list;
queue.add(root);
while (!queue.isEmpty()){
Node t=queue.remove();
if(t.getLeft()!=null)
queue.add(t.getLeft());
if(t.getRight()!=null)
queue.add(t.getRight());
list.add(t.getValue());
}
return list;
}
运用了list链表的先进先出