Skip to content

Commit 6325916

Browse files
committed
bst 删除俩孩子注释
1 parent ff3cd19 commit 6325916

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Python 抽象程度比较高, 我们能用更少的代码来实现功能,同
9191
的基本语法和面向对象编程的一些概念,我们这里只使用最基本的 Python 语法,不会再去介绍用到的 Python 语法糖。
9292

9393
# 预备知识
94-
- 有一定的 python 基础,掌握 Python 基本语法,了解 python 内置数据结构的使用方式。有过使用 Python 的经验。知道 class、module、yield 等
94+
- 有一定的 python 基础,掌握 Python 基本语法,了解 python 内置数据结构的使用方式。有过使用 Python 的经验。知道 class、module、yield 等。如果是 python 初学者,建议先补补基础,否则有些部分看着会比较吃力。
9595
- 基本的面向对象编程知识,会定义和使用 Python 中的类 (class)
9696
- 知道 Python 中的魔术方法,比如 `__len__` `__contains__`
9797
- 无需太多数学基础,仅在算法时间复杂度分析的时候会用到一些简单数学知识。对于学习基础算法,逻辑思维可能更重要一些

docs/17_二叉查找树/bst.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def _bst_remove(self, subtree, key):
104104
return subtree.left # 返回它的孩子并让它的父亲指过去
105105
else:
106106
return subtree.right
107-
else: # 俩孩子,寻找后继节点替换
107+
else: # 俩孩子,寻找后继节点替换,并删除其右子树的后继节点,同时更新其右子树
108108
successor_node = self._bst_min_node(subtree.right)
109109
subtree.key, subtree.value = successor_node.key, successor_node.value
110110
subtree.right = self._bst_remove(subtree.right, successor_node.key)

0 commit comments

Comments
 (0)