二叉树c语言实现 二叉树遍历,求C或C 的源代码?

二叉树遍历,求C或C 的源代码?1:二叉树节点的定义:[R2:二叉树创建一个节点的函数,返回值是指向该节点的指针:[R 3:将二叉树插入节点的函数:[R 4:二叉树的遍历(三种,这里是中间顺序遍历)

二叉树遍历,求C或C 的源代码?

1:二叉树节点的定义:[R

2:二叉树创建一个节点的函数,返回值是指向该节点的指针:[R 3:将二叉树插入节点的函数:[R 4:二叉树的遍历(三种,这里是中间顺序遍历),使用递归:[R 5:二叉树的深度,递归:[R 6:主函数:[R 7:要添加的头文件:[R]

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

#Include

#Include

struct bitnode*stack[100

]struct bitnode//define struct

{

char data

struct bitnode*lchild,*rchild

}

void later(struct bitnode*&)//预订单创建树

{

char Ch

scanf(%C“,& CH)

if(CH=”)

P=null

else

{

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

P->data=CH

later(P->lchild)

later(P->rchild)

}

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

{

int i=-1(1)

]{

而(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)]}