mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 12:58:42 +08:00
Update .gitignore
Add build script for Zig.
This commit is contained in:
@ -228,7 +228,9 @@ G. M. Adelson-Velsky 和 E. M. Landis 在其 1962 年发表的论文 "An algorit
|
||||
=== "Zig"
|
||||
|
||||
```zig title="avl_tree.zig"
|
||||
[class]{AVLTree}-[func]{height}
|
||||
|
||||
[class]{AVLTree}-[func]{updateHeight}
|
||||
```
|
||||
|
||||
### 结点平衡因子
|
||||
@ -294,7 +296,7 @@ G. M. Adelson-Velsky 和 E. M. Landis 在其 1962 年发表的论文 "An algorit
|
||||
=== "Zig"
|
||||
|
||||
```zig title="avl_tree.zig"
|
||||
|
||||
[class]{AVLTree}-[func]{balanceFactor}
|
||||
```
|
||||
|
||||
!!! note
|
||||
@ -386,7 +388,7 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
|
||||
=== "Zig"
|
||||
|
||||
```zig title="avl_tree.zig"
|
||||
|
||||
[class]{AVLTree}-[func]{rightRotate}
|
||||
```
|
||||
|
||||
### Case 2 - 左旋
|
||||
@ -460,7 +462,7 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
|
||||
=== "Zig"
|
||||
|
||||
```zig title="avl_tree.zig"
|
||||
|
||||
[class]{AVLTree}-[func]{leftRotate}
|
||||
```
|
||||
|
||||
### Case 3 - 先左后右
|
||||
@ -553,7 +555,7 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
|
||||
=== "Zig"
|
||||
|
||||
```zig title="avl_tree.zig"
|
||||
|
||||
[class]{AVLTree}-[func]{rotate}
|
||||
```
|
||||
|
||||
## 7.4.3. AVL 树常用操作
|
||||
@ -637,7 +639,9 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
|
||||
=== "Zig"
|
||||
|
||||
```zig title="avl_tree.zig"
|
||||
[class]{AVLTree}-[func]{insert}
|
||||
|
||||
[class]{AVLTree}-[func]{insertHelper}
|
||||
```
|
||||
|
||||
### 删除结点
|
||||
@ -733,7 +737,11 @@ AVL 树的独特之处在于「旋转 Rotation」的操作,其可 **在不影
|
||||
=== "Zig"
|
||||
|
||||
```zig title="avl_tree.zig"
|
||||
[class]{AVLTree}-[func]{remove}
|
||||
|
||||
[class]{AVLTree}-[func]{removeHelper}
|
||||
|
||||
[class]{AVLTree}-[func]{getInOrderNext}
|
||||
```
|
||||
|
||||
### 查找结点
|
||||
|
||||
@ -92,7 +92,7 @@ comments: true
|
||||
=== "Zig"
|
||||
|
||||
```zig title="binary_search_tree.zig"
|
||||
|
||||
[class]{BinarySearchTree}-[func]{search}
|
||||
```
|
||||
|
||||
### 插入结点
|
||||
@ -163,7 +163,7 @@ comments: true
|
||||
=== "Zig"
|
||||
|
||||
```zig title="binary_search_tree.zig"
|
||||
|
||||
[class]{BinarySearchTree}-[func]{insert}
|
||||
```
|
||||
|
||||
为了插入结点,需要借助 **辅助结点 `pre`** 保存上一轮循环的结点,这样在遍历到 $\text{null}$ 时,我们也可以获取到其父结点,从而完成结点插入操作。
|
||||
@ -275,7 +275,9 @@ comments: true
|
||||
=== "Zig"
|
||||
|
||||
```zig title="binary_search_tree.zig"
|
||||
[class]{BinarySearchTree}-[func]{remove}
|
||||
|
||||
[class]{BinarySearchTree}-[func]{getInOrderNext}
|
||||
```
|
||||
|
||||
### 排序
|
||||
|
||||
@ -75,7 +75,7 @@ comments: true
|
||||
=== "Zig"
|
||||
|
||||
```zig title="binary_tree_bfs.zig"
|
||||
|
||||
[class]{}-[func]{hierOrder}
|
||||
```
|
||||
|
||||
## 7.2.2. 前序、中序、后序遍历
|
||||
@ -187,7 +187,11 @@ comments: true
|
||||
=== "Zig"
|
||||
|
||||
```zig title="binary_tree_dfs.zig"
|
||||
[class]{}-[func]{preOrder}
|
||||
|
||||
[class]{}-[func]{inOrder}
|
||||
|
||||
[class]{}-[func]{postOrder}
|
||||
```
|
||||
|
||||
!!! note
|
||||
|
||||
Reference in New Issue
Block a user