void LevelorderTraversal( BinTree BT )
{
BinTree p;
BinTree Q[100];//足够大
int head=0,rear=0;
if(BT){
Q[rear++]=BT;
while(rear!=head){
p=Q[head++];
printf(" %c",p->Data);
if(p->Left!=NULL)
Q[rear++]=p->Left;
if(p->Right!=NULL)
Q[rear++]=p->Right;
}
}
}
中序非递归(栈)
int InOrder(BiTree T)
{
BiTree p;
InitStack(S);
p=T;
while(p||!EmptyStack(S))
{
if(p){
Push(S,p);
p=p->lchild;
}
else
{
Pop(S,q);
printf("%c ",q->data);
p=q->rchild;
}
return 1;
}