This commit is contained in:
krahets
2023-10-15 21:18:21 +08:00
parent eda4539790
commit e181f9b491
10 changed files with 33 additions and 33 deletions

View File

@@ -1357,7 +1357,7 @@ comments: true
```c title="binary_search_tree.c"
/* 删除节点 */
// 由于引入了 stdio.h ,此处无法使用 remove 关键词
void removeNode(binarySearchTree *bst, int num) {
void removeItem(binarySearchTree *bst, int num) {
// 若树为空,直接提前返回
if (bst->root == NULL)
return;
@@ -1399,7 +1399,7 @@ comments: true
}
int tmpVal = tmp->val;
// 递归删除节点 tmp
removeNode(bst, tmp->val);
removeItem(bst, tmp->val);
// 用 tmp 覆盖 cur
cur->val = tmpVal;
}