We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 947b490 commit e6a99b2Copy full SHA for e6a99b2
c-cpp/24_tree/binarysearchtree.c
@@ -95,18 +95,26 @@ Status Delete(BTreePtr T, ElemType e) {
95
}
96
97
//有一个节点
98
- if ((p->lchild != NULL) || (p->rchild != NULL)) {
+ if ((p->lchild != NULL) || (p->rchild != NULL)) { //应该将原有的pp同child连接在一起
99
100
if (p->lchild) {
101
child = p->lchild;
102
} else {
103
child = p->rchild;
104
105
+ if(pp->data>p->data)
106
+ {
107
+ pp->lchild=child;
108
+ } else
109
110
+ pp->rchild=child;
111
+ }
112
free(p);
113
+ return TRUE;
114
115
116
//没有节点
- if (pp->lchild == p) {
117
+ if (pp->lchild == p) {//这里面临pp除p以外的节点为null的情况
118
pp->lchild = child;
119
120
pp->rchild = child;
0 commit comments