mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-11-14 06:52:59 +08:00
Update READMEs.
This commit is contained in:
parent
e53f5f909d
commit
b65a992452
40
README.md
40
README.md
@ -216,27 +216,27 @@ Below is the list of some of the most used Big O notations and their performance
|
|||||||
### Data Structure Operations Complexity
|
### Data Structure Operations Complexity
|
||||||
|
|
||||||
| Data Structure | Access | Search | Insertion | Deletion | Comments |
|
| Data Structure | Access | Search | Insertion | Deletion | Comments |
|
||||||
| ----------------------- | :-------: | :-------: | :-------: | :-------: | :-------- |
|
| ----------------------- | :---------: | :---------: | :---------: | :---------: | :-------- |
|
||||||
| **Array** | 1 | n | n | n | |
|
| **Array** | `1` | `n` | `n` | `n` | |
|
||||||
| **Stack** | n | n | 1 | 1 | |
|
| **Stack** | `n` | `n` | `1` | `1` | |
|
||||||
| **Queue** | n | n | 1 | 1 | |
|
| **Queue** | `n` | `n` | `1` | `1` | |
|
||||||
| **Linked List** | n | n | 1 | 1 | |
|
| **Linked List** | `n` | `n` | `1` | `1` | |
|
||||||
| **Hash Table** | - | n | n | n | In case of perfect hash function costs would be O(1) |
|
| **Hash Table** | - | `n` | `n` | `n` | In case of perfect hash function costs would be `O(1)` |
|
||||||
| **Binary Search Tree** | n | n | n | n | In case of balanced tree costs would be O(log(n)) |
|
| **Binary Search Tree** | `n` | `n` | `n` | `n` | In case of balanced tree costs would be `O(log(n))` |
|
||||||
| **B-Tree** | log(n) | log(n) | log(n) | log(n) | |
|
| **B-Tree** | `log(n)` | `log(n)` | `log(n)` | `log(n)` | |
|
||||||
| **Red-Black Tree** | log(n) | log(n) | log(n) | log(n) | |
|
| **Red-Black Tree** | `log(n)` | `log(n)` | `log(n)` | `log(n)` | |
|
||||||
| **AVL Tree** | log(n) | log(n) | log(n) | log(n) | |
|
| **AVL Tree** | `log(n)` | `log(n)` | `log(n)` | `log(n)` | |
|
||||||
|
|
||||||
### Array Sorting Algorithms Complexity
|
### Array Sorting Algorithms Complexity
|
||||||
|
|
||||||
| Name | Best | Average | Worst | Memory | Stable | Comments |
|
| Name | Best | Average | Worst | Memory | Stable | Comments |
|
||||||
| --------------------- | :-------: | :-------: | :-----------: | :-------: | :-------: | :-------- |
|
| --------------------- | :---------: | :---------: | :-------------: | :---------: | :-------: | :-------- |
|
||||||
| **Bubble sort** | n | n^2 | n^2 | 1 | Yes | |
|
| **Bubble sort** | `n` | `n^2` | `n^2` | `1` | Yes | |
|
||||||
| **Insertion sort** | n | n^2 | n^2 | 1 | Yes | |
|
| **Insertion sort** | `n ` | `n^2` | `n^2` | `1` | Yes | |
|
||||||
| **Selection sort** | n^2 | n^2 | n^2 | 1 | No | |
|
| **Selection sort** | `n^2` | `n^2` | `n^2` | `1` | No | |
|
||||||
| **Heap sort** | n log(n) | n log(n) | n log(n) | 1 | No | |
|
| **Heap sort** | `n log(n)` | `n log(n)` | `n log(n)` | `1` | No | |
|
||||||
| **Merge sort** | n log(n) | n log(n) | n log(n) | n | Yes | |
|
| **Merge sort** | `n log(n)` | `n log(n)` | `n log(n)` | `n` | Yes | |
|
||||||
| **Quick sort** | n log(n) | n log(n) | n^2 | log(n) | No | |
|
| **Quick sort** | `n log(n)` | `n log(n)` | `n^2` | `log(n)` | No | |
|
||||||
| **Shell sort** | n log(n) | depends on gap sequence | n (log(n))^2 | 1 | No | |
|
| **Shell sort** | `n log(n)` | depends on gap sequence | `n (log(n))^2` | `1` | No | |
|
||||||
| **Counting sort** | n + r | n + r | n + r | n + r | Yes | r - biggest number in array |
|
| **Counting sort** | `n + r` | `n + r` | `n + r` | `n + r` | Yes | `r` - biggest number in array |
|
||||||
| **Radix sort** | n * k | n * k | n * k | n + k | Yes | k - length of longest key |
|
| **Radix sort** | `n * k` | `n * k` | `n * k` | `n + k` | Yes | `k` - length of longest key |
|
||||||
|
@ -11,9 +11,15 @@ are needed, which indicates that the list is sorted.
|
|||||||
|
|
||||||
## Complexity
|
## Complexity
|
||||||
|
|
||||||
###### time: worst _O_(_n_<sup>2</sup>), best _O_(_n_), average _O_(_n_<sup>2</sup>)
|
Time
|
||||||
|
|
||||||
###### space: worst _O_(1) auxiliary
|
- worst _O_(_n_<sup>2</sup>),
|
||||||
|
- best _O_(_n_),
|
||||||
|
- average _O_(_n_<sup>2</sup>)
|
||||||
|
|
||||||
|
Space
|
||||||
|
|
||||||
|
worst _O_(1) auxiliary
|
||||||
|
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
Loading…
Reference in New Issue
Block a user