69,371
社区成员
发帖
与我相关
我的任务
分享
BSTree *q, s;
...
q = bst;
while (*q) {
if (K==(*q)->key)
{
free(s);
return 0;
}
if (K<(*q)->key)
q = &(*q)->lchild;
else
q = &(*q)->rchild;
}
*q = s;
while (q) {
p = q;
if (K==q->key)
{
free(s);
return 0;
}
if (K<q->key)
{
q = q->lchild;
if (q == NULL)
p->lchild = s;
}
else
{
q = q->rchild;
if (q == NULL)
p->rchild = s;
}
}
...