mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-12 07:26:07 +00:00
build
This commit is contained in:
@@ -1140,6 +1140,12 @@ Constant order means the number of operations is independent of the input data s
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{constant}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -1312,6 +1318,12 @@ Linear order indicates the number of operations grows linearly with the input da
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{linear}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -1499,6 +1511,12 @@ Operations like array traversal and linked list traversal have a time complexity
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{array_traversal}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -1713,6 +1731,12 @@ Quadratic order means the number of operations grows quadratically with the inpu
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{quadratic}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -2013,6 +2037,12 @@ For instance, in bubble sort, the outer loop runs $n - 1$ times, and the inner l
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{bubble_sort}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -2269,6 +2299,12 @@ The following image and code simulate the cell division process, with a time com
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{exponential}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -2432,6 +2468,12 @@ In practice, exponential order often appears in recursive functions. For example
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{exp_recur}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -2623,6 +2665,12 @@ The following image and code simulate the "halving each round" process, with a t
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{logarithmic}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -2780,6 +2828,12 @@ Like exponential order, logarithmic order also frequently appears in recursive f
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{log_recur}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -2988,6 +3042,12 @@ Linear-logarithmic order often appears in nested loops, with the complexities of
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{linear_log_recur}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -3214,6 +3274,12 @@ Factorials are typically implemented using recursion. As shown in the image and
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="time_complexity.rb"
|
||||
[class]{}-[func]{factorial_recur}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="time_complexity.zig"
|
||||
@@ -3603,6 +3669,14 @@ The "worst-case time complexity" corresponds to the asymptotic upper bound, deno
|
||||
}
|
||||
```
|
||||
|
||||
=== "Ruby"
|
||||
|
||||
```ruby title="worst_best_time_complexity.rb"
|
||||
[class]{}-[func]{random_numbers}
|
||||
|
||||
[class]{}-[func]{find_one}
|
||||
```
|
||||
|
||||
=== "Zig"
|
||||
|
||||
```zig title="worst_best_time_complexity.zig"
|
||||
|
||||
Reference in New Issue
Block a user