mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-16 16:56:06 +00:00
build
This commit is contained in:
@@ -214,11 +214,3 @@ comments: true
|
||||
|
||||
[class]{}-[func]{binary_search}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="binary_search_recur.zig"
|
||||
[class]{}-[func]{dfs}
|
||||
|
||||
[class]{}-[func]{binarySearch}
|
||||
```
|
||||
|
||||
@@ -248,14 +248,6 @@ $m$ の問い合わせの効率を向上させるために、ハッシュテー
|
||||
[class]{}-[func]{build_tree}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="build_tree.zig"
|
||||
[class]{}-[func]{dfs}
|
||||
|
||||
[class]{}-[func]{buildTree}
|
||||
```
|
||||
|
||||
以下の図は、二分木を構築する再帰過程を示しています。各ノードは再帰の「下降」段階で作成され、各エッジ(参照)は「上昇」段階で形成されます。
|
||||
|
||||
=== "<1>"
|
||||
|
||||
@@ -295,16 +295,6 @@ $f(2)$ を解決する過程は次のように要約できます:**`B` の助
|
||||
[class]{}-[func]{solve_hanota}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="hanota.zig"
|
||||
[class]{}-[func]{move}
|
||||
|
||||
[class]{}-[func]{dfs}
|
||||
|
||||
[class]{}-[func]{solveHanota}
|
||||
```
|
||||
|
||||
以下の図に示すように、ハノイの塔問題は高さ $n$ の再帰木として視覚化できます。各ノードは部分問題を表し、`dfs()` の呼び出しに対応します。**したがって、時間計算量は $O(2^n)$、空間計算量は $O(n)$ です。**
|
||||
|
||||
{ class="animation-figure" }
|
||||
|
||||
Reference in New Issue
Block a user