Add counting sort.

This commit is contained in:
Oleksii Trekhleb 2018-05-29 07:36:41 +03:00
parent 0c1f6851d5
commit e3ff82fcba

View File

@ -217,13 +217,13 @@ Below is the list of some of the most used Big O notations and their performance
### Array Sorting Algorithms Complexity
| Name | Best | Average | Worst | Memory | Stable |
| --------------------- | :-------: | :-------: | :-----------: | :-------: | :-------: |
| **Bubble 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 |
| **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 |
| **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 |
| **Counting sort** | n + r | n + r | n + r | n + r | Yes |
| Name | Best | Average | Worst | Memory | Stable | Comments |
| --------------------- | :-------: | :-------: | :-----------: | :-------: | :-------: | :-------- |
| **Bubble 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 | |
| **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 | |
| **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 | |
| **Counting sort** | n + r | n + r | n + r | n + r | Yes | r - biggest number in sorted array |