This commit is contained in:
krahets
2024-03-31 03:53:04 +08:00
parent 87af663929
commit c23e576da4
68 changed files with 2139 additions and 22 deletions
@@ -1077,6 +1077,14 @@ Note that memory occupied by initializing variables or calling functions in a lo
}
```
=== "Ruby"
```ruby title="space_complexity.rb"
[class]{}-[func]{function}
[class]{}-[func]{constant}
```
=== "Zig"
```zig title="space_complexity.zig"
@@ -1373,6 +1381,12 @@ Linear order is common in arrays, linked lists, stacks, queues, etc., where the
}
```
=== "Ruby"
```ruby title="space_complexity.rb"
[class]{}-[func]{linear}
```
=== "Zig"
```zig title="space_complexity.zig"
@@ -1549,6 +1563,12 @@ As shown below, this function's recursive depth is $n$, meaning there are $n$ in
}
```
=== "Ruby"
```ruby title="space_complexity.rb"
[class]{}-[func]{linear_recur}
```
=== "Zig"
```zig title="space_complexity.zig"
@@ -1783,6 +1803,12 @@ Quadratic order is common in matrices and graphs, where the number of elements i
}
```
=== "Ruby"
```ruby title="space_complexity.rb"
[class]{}-[func]{quadratic}
```
=== "Zig"
```zig title="space_complexity.zig"
@@ -1972,6 +1998,12 @@ As shown below, the recursive depth of this function is $n$, and in each recursi
}
```
=== "Ruby"
```ruby title="space_complexity.rb"
[class]{}-[func]{quadratic_recur}
```
=== "Zig"
```zig title="space_complexity.zig"
@@ -2164,6 +2196,12 @@ Exponential order is common in binary trees. Observe the below image, a "full bi
}
```
=== "Ruby"
```ruby title="space_complexity.rb"
[class]{}-[func]{build_tree}
```
=== "Zig"
```zig title="space_complexity.zig"