【LeetCode】Binary Tree Level Order Traversal

来源:互联网 发布:崩坏学园2源码 编辑:程序博客网 时间:2024/06/04 20:14

题目描述

Binary Tree Level Order Traversal

 

Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).

For example:
Given binary tree {3,9,20,#,#,15,7},

    3   / \  9  20    /  \   15   7

return its level order traversal as:

[  [3],  [9,20],  [15,7]]

confused what "{1,#,2,3}" means? > read more on how binary tree is serialized on OJ.


题目分析

树按层遍历

总结

使用队列

代码示例




推荐学习C++的资料

C++标准函数库
http://download.csdn.net/detail/chinasnowwolf/7108919
在线C++API查询
http://www.cplusplus.com/
queue使用方法
http://www.cplusplus.com/reference/queue/queue/



0 0