# Leetcode 94. Binary Tree Inorder Traversal

/**
* Definition for a binary tree node.
* struct TreeNode {
*     int val;
*     TreeNode *left;
*     TreeNode *right;
*     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
vector<int> inorderTraversal(TreeNode* root) {
vector<int> ret;
if(root == NULL)
return ret;
stack <pair<TreeNode *,bool> > tree;
//pair<TreeNode *,bool> *p;
TreeNode *p;
bool depose;

tree.push(make_pair(root,false));
while(!tree.empty()){
p = tree.top().first;
depose = tree.top().second;
tree.pop();

if(!depose){//未展开

if(p->right != NULL)            //左子树
tree.push(make_pair(p->right,false));
tree.push(make_pair(p,true));   //根，记为ture，表示已展开过
if(p->left != NULL)             //右子树
tree.push(make_pair(p->left,false));
}else{
ret.push_back(p->val);
}

}
return ret;
}
};

#### LeetCode94 BinaryTreeInorderTraversal Java题解（递归 迭代）

2015-07-08 09:57:06

#### LeetCode 94 Binary Tree Inorder Traversal(Python详解及实现)

2017-08-10 16:10:57

#### 【LeetCode】94. Binary Tree Inorder Traversal 解题报告

2016-05-22 23:59:26

#### Binary Tree Inorder Traversal -- LeetCode

2014-03-01 05:38:48

#### 【LeetCode】【Python】Binary Tree Inorder Traversal

2014-07-25 09:34:45

#### LeetCode 94：Binary Tree Inorder Traversal（中序遍历）

2015-06-01 19:06:05

#### 【LeetCode】94. Binary Tree Inorder Traversal-二叉树中序遍历

2017-03-28 10:37:28

#### [leetcode-94]Binary Tree Inorder Traversal（c++)

2015-08-10 14:19:07

#### 【LeetCode】105. Construct Binary Tree from Preorder and Inorder Traversal 解题报告

2016-06-01 23:42:08

#### C++详解Leetcode:105. Construct Binary Tree from Preorder and Inorder Traversal

2017-07-30 17:34:05