mirror of
https://github.com/krahets/hello-algo.git
synced 2026-08-17 14:10:57 +00:00
build
This commit is contained in:
@@ -1450,7 +1450,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
|
||||
```python title="avl_tree.py"
|
||||
def insert(self, val) -> None:
|
||||
"""插入节点"""
|
||||
self.__root = self.__insert_helper(self.__root, val)
|
||||
self.root = self.__insert_helper(self.root, val)
|
||||
|
||||
def __insert_helper(self, node: TreeNode | None, val: int) -> TreeNode:
|
||||
"""递归插入节点(辅助方法)"""
|
||||
@@ -1800,7 +1800,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
|
||||
```python title="avl_tree.py"
|
||||
def remove(self, val: int) -> None:
|
||||
"""删除节点"""
|
||||
self.__root = self.__remove_helper(self.__root, val)
|
||||
self.root = self.__remove_helper(self.root, val)
|
||||
|
||||
def __remove_helper(self, node: TreeNode | None, val: int) -> TreeNode | None:
|
||||
"""递归删除节点(辅助方法)"""
|
||||
|
||||
@@ -804,7 +804,7 @@ comments: true
|
||||
pre.right = child
|
||||
else:
|
||||
# 若删除节点为根节点,则重新指定根节点
|
||||
self.__root = child
|
||||
self.root = child
|
||||
# 子节点数量 = 2
|
||||
else:
|
||||
# 获取中序遍历中 cur 的下一个节点
|
||||
|
||||
Reference in New Issue
Block a user