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

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

#Include

#Include

structbitnode*stack[100

]structbitnode//definestruct

{

chardata

structbitnode*lchild,*rchild

}

voidlater(structbitnode*&)//preordercreatetree

{

charCh

scanfscanf(%C”,&;Ch)

if(Ch=”)

P=null

else{

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

P->data=ch

以后(P->lchild)

以后(P->rchild)

}

voidprint(structbitnode*P)//前序遍历(输出二叉树)

{

inti=-1

while(1)

{

whileP!=null)

]{

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

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

P=P->lchild

}]如果(I!=-1)

{

P=stack[i

]i-->]else

return

}

voidmain()//主函数

{

structbitnode*P,*t

稍后(P)

print(P)]}

二叉树的层次遍历代码C语言二叉树中序遍历算法二叉树的遍历程序详解