This commit is contained in:
krahets
2023-08-20 14:52:31 +08:00
parent 44a8568356
commit 68e11cfa34
40 changed files with 239 additions and 235 deletions
+12 -12
View File
@@ -1139,7 +1139,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return leftRotate(node);
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node;
}
```
@@ -1173,7 +1173,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return leftRotate(node);
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node;
}
```
@@ -1203,7 +1203,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
# 先右旋后左旋
node.right = self.__right_rotate(node.right)
return self.__left_rotate(node)
# 平衡树,无旋转,直接返回
# 平衡树,无旋转,直接返回
return node
```
@@ -1237,7 +1237,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return t.leftRotate(node)
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node
}
```
@@ -1271,7 +1271,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return this.#leftRotate(node);
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node;
}
```
@@ -1305,7 +1305,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return this.leftRotate(node);
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node;
}
```
@@ -1339,7 +1339,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return leftRotate(node);
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node;
}
```
@@ -1373,7 +1373,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return leftRotate(node);
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node;
}
```
@@ -1407,7 +1407,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return leftRotate(node: node)
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node
}
```
@@ -1441,7 +1441,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return self.leftRotate(node);
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node;
}
```
@@ -1475,7 +1475,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
return leftRotate(node);
}
}
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
return node;
}
```
@@ -1513,7 +1513,7 @@ AVL 树的特点在于「旋转 Rotation」操作,它能够在不影响二叉
Self::left_rotate(Some(node))
}
} else {
// 平衡树,无旋转,直接返回
// 平衡树,无旋转,直接返回
node
}
}
+1 -1
View File
@@ -1478,7 +1478,7 @@ comments: true
我们知道,二叉树的中序遍历遵循“左 $\rightarrow$ 根 $\rightarrow$ 右”的遍历顺序,而二叉搜索树满足“左子节点 $<$ 根节点 $<$ 右子节点”的大小关系。因此,在二叉搜索树中进行中序遍历时,总是会优先遍历下一个最小节点,从而得出一个重要性质:**二叉搜索树的中序遍历序列是升序的**。
利用中序遍历升序的性质,我们在二叉搜索树中获取有序数据仅需 $O(n)$ 时间,无额外排序,非常高效。
利用中序遍历升序的性质,我们在二叉搜索树中获取有序数据仅需 $O(n)$ 时间,无额外排序,非常高效。
![二叉搜索树的中序遍历序列](binary_search_tree.assets/bst_inorder_traversal.png)