Release Rust code to documents. (#656)

This commit is contained in:
Yudong Jin
2023-07-26 11:00:53 +08:00
committed by GitHub
parent 60162f6fa8
commit 027bdd6510
61 changed files with 1155 additions and 145 deletions
@@ -127,3 +127,11 @@
[class]{}-[func]{binarySearch}
```
=== "Rust"
```rust title="binary_search_recur.rs"
[class]{}-[func]{dfs}
[class]{}-[func]{binary_search}
```
@@ -147,6 +147,14 @@
[class]{}-[func]{buildTree}
```
=== "Rust"
```rust title="build_tree.rs"
[class]{}-[func]{dfs}
[class]{}-[func]{build_tree}
```
下图展示了构建二叉树的递归过程,各个节点是在向下“递”的过程中建立的,而各条边(即引用)是在向上“归”的过程中建立的。
=== "<1>"
@@ -192,6 +192,16 @@
[class]{}-[func]{hanota}
```
=== "Rust"
```rust title="hanota.rs"
[class]{}-[func]{move_pan}
[class]{}-[func]{dfs}
[class]{}-[func]{hanota}
```
如下图所示,汉诺塔问题形成一个高度为 $n$ 的递归树,每个节点代表一个子问题、对应一个开启的 `dfs()` 函数,**因此时间复杂度为 $O(2^n)$ ,空间复杂度为 $O(n)$** 。
![汉诺塔问题的递归树](hanota_problem.assets/hanota_recursive_tree.png)