mirror of
https://github.moeyy.xyz/https://github.com/trekhleb/javascript-algorithms.git
synced 2024-12-26 23:21:18 +08:00
Add counting sort.
This commit is contained in:
parent
0c1f6851d5
commit
e3ff82fcba
20
README.md
20
README.md
@ -217,13 +217,13 @@ Below is the list of some of the most used Big O notations and their performance
|
|||||||
|
|
||||||
### Array Sorting Algorithms Complexity
|
### Array Sorting Algorithms Complexity
|
||||||
|
|
||||||
| Name | Best | Average | Worst | Memory | Stable |
|
| 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 |
|
| **Counting sort** | n + r | n + r | n + r | n + r | Yes | r - biggest number in sorted array |
|
||||||
|
Loading…
Reference in New Issue
Block a user