二叉树的镜像
代码实现
int tree_mirror(TreeNode *bt)
{
if(NULL == bt){
cout<<"tree is empty\n";
}
TreeNode *temp;
stack<TreeNode *> st;
while(1){
temp = bt->lchild;
bt->lchild = bt->rchild;
bt->rchild = temp;
if(bt->rchild)
st.push(bt->rchild);
if(bt->lchild)
bt = bt->lchild;
else{
if(st.empty())
break;
bt = st.top();
st.pop();
}
}
}