数据结构
struct {
int value;
Node* left;
Node* right;
} Node;
经典题目
1. 中序遍历
解法:递归
visit(root->left, result);
result.push(root);
visit(root->right, result);
解决2:迭代
while(root != null && stack != null) {
// visit left tree to stack
while(root != null..) {
stack.push(root);
root = root->left;
}
// visit central Node
root = stack.pop()
result.push(root)
// visit right Tree
root = root.right
}