Binary Tree Inorder Traversal
来源:互联网 发布:怎么查淘宝买家信息 编辑:程序博客网 时间:2024/06/15 08:28
Given a binary tree, return the inorder traversal of its nodes’ values.
For example: Given binary tree {1,#,2,3},
1
\
2
/
3
return [1,3,2].
Note: Recursive solution is trivial, could you do it iteratively?
题意:中序遍历
vector<int> InOrderTraversal(TreeNode *root) { vector<int> path; stack<TreeNode*> stk; while(root != NULL || !stk.empty()) { while(root != NULL) { stk.push(root); root = root->left; } if( !stk.empty()) { root = stk.top(); stk.pop(); root = root->right; } } return path; }
0 0
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- Binary Tree Inorder Traversal
- 如何让 IIS Express 支持其他机器访问
- 微信公众帐号开发教程第1篇-引言
- [H2]嵌入式数据库配置及自定义函数扩展
- phpMyAdmin 安装配置
- iOS7自定义视图控制器过渡3-关于Push和Pop的过渡
- Binary Tree Inorder Traversal
- 【美团】外卖配送事业部面试
- MVC 原理
- Sql server2008 判断字段不为空
- Xcode - ld: library not found for -lPods -******* 错误
- 微信公众帐号开发教程第3篇-开发模式启用及接口配置
- 利用ajax的getJSON读取数据时注意的问题
- 《开源框架那点事儿34》:Tiny模板语言(VelocityPlus)初步入门
- iOS CGAffineTransform属性