遍历二叉树口诀 用C语言编程实现二叉树的中序遍历算法?

用C语言编程实现二叉树的中序遍历算法?#Include#Includestruct bitnode*stack[100]struct bitnode//define struct{char datas

用C语言编程实现二叉树的中序遍历算法?

#Include

#Include

struct bitnode*stack[100

]struct bitnode//define struct

{

char data

struct bitnode*lchild,*rchild

}

void later(struct bitnode*&)//preorder create tree

{

char Ch

scanf scanf(%C”,&;Ch)

if(Ch=”)

P=null

else{

P=(struct bitnode*)malloc(sizeof(struct bitnode*)bitnode)

P->data=ch

以后(P->lchild)

以后(P->rchild)

}

void print(struct bitnode*P)//前序遍历(输出二叉树)

{

int i=-1

while(1)

{

while P!=null)

]{

堆栈[i]=P->rchild/*printf(”确定?N“)*/

printf(”%C“,P->data)

P=P->lchild

}]如果(I!=-1)

{

P=stack[i

]i-->]else

return

}

void main()//主函数

{

struct bitnode*P,*t

稍后(P)

print(P)]}