67.二叉树的中序遍历
来源:互联网 发布:对万方数据库的评价 编辑:程序博客网 时间:2024/05/02 04:21
题目:给出一棵二叉树,返回其中序遍历。
样例:
给出二叉树 {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. */ void in(vector<int> &v,TreeNode *root) { if(root==NULL) return; else { in(v,root->left); v.push_back(root->val); in(v,root->right); } }public: vector<int> inorderTraversal(TreeNode *root) { // write your code here vector<int> v; in(v,root); return v; }};感想:同前序遍历一样。
1 0
- 67.二叉树的中序遍历
- 67.二叉树的中序遍历
- 二叉树的中序遍历
- 二叉树的中序遍历
- 线索二叉树的中序遍历
- 有关二叉树的中序遍历
- 二叉树的中序遍历
- 排序二叉树的中序遍历
- 二叉树的中序遍历算法
- 题目:二叉树的中序遍历
- 二叉树的中序遍历
- 二叉树的中序遍历
- 二叉树的中序遍历
- LintCode -- 二叉树的中序遍历
- lintcode 二叉树的中序遍历
- 二叉树的前后中序遍历
- 二叉树的中序遍历
- 二叉树的中序遍历
- C#中文转Unicode、Unicode转中文
- 莫队算法
- [D3D9] D3DFVF_XYZ、D3DFVF_XYZRHW 的区别 (以纹理渲染的代码举例说明)
- Watson Explorer 入门(3):创建搜寻器(crawler,数据爬虫)
- java水杯
- 67.二叉树的中序遍历
- 数据结构
- Unity汽车插件 RealisticCarControllerV3使用记录
- 用myeclipse构建maven project时候出现报错:Unable to create project from archetype
- 查看端口占用
- Head First SQL 第七章
- 把MSSQL数据表转为图表显示
- 元件引脚直径与PCB焊盘孔径对应关系
- 深度学习之理解神经网络的四个公式