前序:
void inorderTraversal(BinTree BT){
BinTree T BT;
Stack S = CreatStack(MaxSize);
while(T||isEmpty(S){
while(T) {
push(S,T);
printf("%d",T->Data);
T=T->Left;
}
if(!isEmpty(S){
T = pop(S);
T=T->Right;
}
}
}
中序:
void inorderTraversal(BinTree BT){
BinTree T BT;
Stack S = CreatStack(MaxSize);
while(T||isEmpty(S){
while(T) {
push(S,T);
T=T->Left;
}
if(!isEmpty(S){
T = pop(S);
printf("%d",T->Data);
T=T->Right;
}
}
}
后序:
void InOrderTraversal( BinTree BT )
{
BinTree T = BT;
Stack S = CreatStack( MaxSize); /*创建并初始化堆栈S * ,
while(T || !Isempty(S)){
while (T) {
Push(ST) ;
T.flag=1;
T->Left ;
}
if( !IsEmpty(S) ){
T = GetTop(S);
if(T.flag = 1){ //初始值为0
T.flag = 2;
T=T->Right;
}else if(T.flag = 2) {
t = pop(S)
printf("%d",t->Data);
T=null;
}
}
}