主题:二叉排序树的删除的算法,要C语言版的
int locate(bitree r,elemtype x)
{if(r==NULL) return NULL;
if(r->Data==x) return x;
else if(r->Data<x)
locate(r->right,x);
else locate(r->left,x);}
bitree Delete(bitree r,elemtype x)
{ bitree f,p,a,b,c,s,h;
locate(r,x);
p=r;
f=r;
if(p==NULL)
{ printf("the delete is fair!\n");
return (NULL);
}
if(p->left==NULL && p->right==NULL)
h=NULL;
else if (p->left==NULL) h=p->right;
else if (p->right==NULL) h=p->left;
else
{a=p->left;
b=p->right;
if (b->left==NULL)
{ h=b;
b->left=a;
}
else
{ h=b;
while (h->left)
{ s=h;
h=h->left;
}
s->left=h->right;
h->right=b;
h->left=a;
}
}
if (f==NULL)
r=h;
else if (f->left==p) f->left=h;
else f->right=h;
return (r);}是那里出了问题,请帮看一下,谢谢!