线索化二叉树
先序序列创建二叉树
tree creat(){ //前序序列创建二叉树
tree t;
int ch;
scanf("%d",&ch);
if(ch==0)
{
t=NULL;}
else{
t=(tree)malloc(sizeof(node));
t->data=ch;
t->lchild=creat();
t->rchild=creat();
}
return t;
}
中序线索化二叉树
void xiansuo(tree t)
{
xiansuo(t->lchild);
if(t->lchild==NULL)
{
t->ltag=1;t->lchild=pre;
}
if(pre!=NULL&&pre->rchild==NULL)
{
pre->rtag=1;
pre->rchild=t;
}
pre=t;
xiansuo(t->rchild);
}