// 中序遍历伪代码:非递归版本,用栈实现,版本1

void InOrder1(TNode* root)

{

Stack S;

while ( root != NULL || !S.empty() )

{

while( root != NULL ) // 左子树入栈

{

S.push(root);

root = root->left;

}

if ( !S.empty() )

{

root = S.pop();

Visit(root->data); // 访问根结点

//这里是不是还要再添加

root=S.top();

Visit(root->data)//

//添加结束

root = root->right; // 通过下一次循环实现右子树遍历

S.top();//添加

}

}

}