mirror of
https://github.com/krahets/hello-algo.git
synced 2026-04-13 18:00:18 +08:00
build
This commit is contained in:
@@ -1448,7 +1448,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
|
||||
=== "Python"
|
||||
|
||||
```python title="avl_tree.py"
|
||||
def insert(self, val) -> None:
|
||||
def insert(self, val):
|
||||
"""插入节点"""
|
||||
self.root = self.__insert_helper(self.root, val)
|
||||
|
||||
@@ -1797,7 +1797,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
|
||||
=== "Python"
|
||||
|
||||
```python title="avl_tree.py"
|
||||
def remove(self, val: int) -> None:
|
||||
def remove(self, val: int):
|
||||
"""删除节点"""
|
||||
self.root = self.__remove_helper(self.root, val)
|
||||
|
||||
|
||||
@@ -349,7 +349,7 @@ comments: true
|
||||
=== "Python"
|
||||
|
||||
```python title="binary_search_tree.py"
|
||||
def insert(self, num: int) -> None:
|
||||
def insert(self, num: int):
|
||||
"""插入节点"""
|
||||
# 若树为空,直接提前返回
|
||||
if self.root is None:
|
||||
@@ -769,7 +769,7 @@ comments: true
|
||||
=== "Python"
|
||||
|
||||
```python title="binary_search_tree.py"
|
||||
def remove(self, num: int) -> None:
|
||||
def remove(self, num: int):
|
||||
"""删除节点"""
|
||||
# 若树为空,直接提前返回
|
||||
if self.root is None:
|
||||
|
||||
@@ -385,7 +385,7 @@ comments: true
|
||||
=== "Python"
|
||||
|
||||
```python title="binary_tree_dfs.py"
|
||||
def pre_order(root: TreeNode | None) -> None:
|
||||
def pre_order(root: TreeNode | None):
|
||||
"""前序遍历"""
|
||||
if root is None:
|
||||
return
|
||||
@@ -394,7 +394,7 @@ comments: true
|
||||
pre_order(root=root.left)
|
||||
pre_order(root=root.right)
|
||||
|
||||
def in_order(root: TreeNode | None) -> None:
|
||||
def in_order(root: TreeNode | None):
|
||||
"""中序遍历"""
|
||||
if root is None:
|
||||
return
|
||||
@@ -403,7 +403,7 @@ comments: true
|
||||
res.append(root.val)
|
||||
in_order(root=root.right)
|
||||
|
||||
def post_order(root: TreeNode | None) -> None:
|
||||
def post_order(root: TreeNode | None):
|
||||
"""后序遍历"""
|
||||
if root is None:
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user