二叉树层次遍历
2016-12-07 23:01
197 查看
void printByLevel(Tree t) { Tree p; queue<Tree> q; q.push(t); while (!q.empty()) { p = q.front(); q.pop(); cout << p->val << " "; if (p->left) q.push(p->left); if (p->right) q.push(p->right); } }
相关文章推荐
- 二叉树的4种遍历方式(前序、中序、后序、层次)Java版
- 第十周项目1 算法验证-二叉树的层次遍历算法
- 非递归层次遍历方法实现二叉树中指定节点的层次数查找
- uva 11234 Expressions(建立二叉树+层次遍历)
- 二叉树的建树、遍历(先序、中序、后序、层次)(递归和非递归)--Java实现
- 二叉树的层次遍历
- 二叉树的层次遍历
- July 微软面试100题 第16题 二叉树的层次遍历
- 二叉树的先序、中序、后序以及层次遍历
- 二叉树的4种遍历:前序,中序,后序,层次遍历
- 二叉树的层次遍历
- 二叉树先序遍历,中序遍历,后序遍历,层次遍历。
- leet102. 二叉树的层次遍历
- LeetCode OJ 之 Binary Tree Zigzag Level Order Traversal (二叉树的曲线层次遍历)
- 二叉树 - 链式二叉树的层次遍历(C语言)
- 二叉树的遍历(递归,非递归,层次)
- 二叉树递归与非递归层次遍历
- 二叉树的层次遍历
- 二叉树--uva122 二叉树层次遍历(结构体+指针解法)
- Binary Tree Level Order Traversal I和II 层次遍历二叉树