mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 21:24:53 +08:00
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:
@ -736,7 +736,7 @@ $$
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
|
||||

|
||||
|
||||
### 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
|
||||
|
||||

|
||||
|
||||
### 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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user