F_G

许多问题需要说清楚就可以&&走永远比跑来的重要

导航

[Leetcode] Binary Tree Level Order Traversal

两种思路

一、level by level

使用两个queue,queue1记录当前访问的层,queue2记录下一个层,最后queue1清空,queue2拷贝至queue1.

 

二、depth first traval

使用参数传递level,在适当的时刻增加层数

 

[1] http://www.cnblogs.com/remlostime/archive/2012/10/27/2742955.html

[2] http://blog.csdn.net/Andrewseu/article/details/25825169

posted on 2015-07-26 10:51  F_G  阅读(119)  评论(0编辑  收藏  举报