Bug fixes and improvements (#1205)

* Add Ruby code blocks to documents

* Remove Ruby code from en/docs

* Remove "center-table" class in index.md

* Add "data-toc-label" to handle the latex heading during the build process

* Use normal JD link instead.

* Bug fixes
This commit is contained in:
Yudong Jin
2024-04-01 19:37:00 +08:00
committed by GitHub
parent 5ce088de52
commit b3f100aff1
30 changed files with 27 additions and 115 deletions

View File

@ -736,7 +736,7 @@ $$
![Common Types of Space Complexity](space_complexity.assets/space_complexity_common_types.png)
### Constant Order $O(1)$ {data-toc-label="Constant Order"}
### Constant Order $O(1)$
Constant order is common in constants, variables, objects that are independent of the size of input data $n$.
@ -746,7 +746,7 @@ Note that memory occupied by initializing variables or calling functions in a lo
[file]{space_complexity}-[class]{}-[func]{constant}
```
### Linear Order $O(n)$ {data-toc-label="Linear Order"}
### Linear Order $O(n)$
Linear order is common in arrays, linked lists, stacks, queues, etc., where the number of elements is proportional to $n$:
@ -762,7 +762,7 @@ As shown below, this function's recursive depth is $n$, meaning there are $n$ in
![Recursive Function Generating Linear Order Space Complexity](space_complexity.assets/space_complexity_recursive_linear.png)
### Quadratic Order $O(n^2)$ {data-toc-label="Quadratic Order"}
### Quadratic Order $O(n^2)$
Quadratic order is common in matrices and graphs, where the number of elements is quadratic to $n$:
@ -778,7 +778,7 @@ As shown below, the recursive depth of this function is $n$, and in each recursi
![Recursive Function Generating Quadratic Order Space Complexity](space_complexity.assets/space_complexity_recursive_quadratic.png)
### Exponential Order $O(2^n)$ {data-toc-label="Exponential Order"}
### Exponential Order $O(2^n)$
Exponential order is common in binary trees. Observe the below image, a "full binary tree" with $n$ levels has $2^n - 1$ nodes, occupying $O(2^n)$ space:
@ -788,7 +788,7 @@ Exponential order is common in binary trees. Observe the below image, a "full bi
![Full Binary Tree Generating Exponential Order Space Complexity](space_complexity.assets/space_complexity_exponential.png)
### Logarithmic Order $O(\log n)$ {data-toc-label="Logarithmic Order"}
### Logarithmic Order $O(\log n)$
Logarithmic order is common in divide-and-conquer algorithms. For example, in merge sort, an array of length $n$ is recursively divided in half each round, forming a recursion tree of height $\log n$, using $O(\log n)$ stack frame space.