二叉树的中序遍历
来源:互联网 发布:tensorflow官网镜像 编辑:程序博客网 时间:2024/06/14 03:25
问题描述:给出一棵二叉树,返回其中序遍历。
样例
给出二叉树 {1,#,2,3}
,
1 \ 2 / 3
返回 [1,3,2]
.
实验代码:
class Solution {
/**
* @param root: The root of binary tree.
* @return: Inorder in vector which contains node values.
*/
vector<int> x;
public:
vector<int> inorderTraversal(TreeNode *root) {
// write your code here
if(root!=NULL)
{
inorderTraversal(root->left);
x.push_back(root->val);
inorderTraversal(root->right);
}
return x;
}
};
个人感想:与前序遍历相似。
0 0
- 二叉树的中序遍历
- 二叉树的中序遍历
- 线索二叉树的中序遍历
- 有关二叉树的中序遍历
- 二叉树的中序遍历
- 排序二叉树的中序遍历
- 二叉树的中序遍历算法
- 题目:二叉树的中序遍历
- 二叉树的中序遍历
- 二叉树的中序遍历
- 二叉树的中序遍历
- LintCode -- 二叉树的中序遍历
- lintcode 二叉树的中序遍历
- 二叉树的前后中序遍历
- 二叉树的中序遍历
- 二叉树的中序遍历
- lintcode:二叉树的中序遍历
- lintcode,二叉树的中序遍历
- 群控源码
- 字符设备驱动
- 《Training:Retrieving File Information》
- 回文子序列 ssl 2662 枚举
- java中的位运算
- 二叉树的中序遍历
- AngularJS 动画
- 基于Doxygen的C/C++注释原则
- js 内存管理
- Extjs3.2第一篇:formPanel的getForm().getValues()提交与处理
- 用java做导出excel的万能方法
- spark常用的transformation
- Java安全之消息摘要
- 学习OpenCV——KeyPoint Matching 优化方式