mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-07-08 10:24:54 +08:00
Added Complexity of Each Algorithm in Sorting/ directory. (#76)
* Added Complexity to Bubble Sort README.md * Added Complexity to Counting-Sort README.md * Italicized n in Bubble Sort README.md * Added Complexity to Heap Sort README.md * Added Complexity to Insertion Sort README.md * Added Complexity to Merge Sort README.md * Added Complexity to Quick Sort README.md * Added Complexity to Radix Sort README.md * Added Complexity to Selection Sort README.md * Added Complexity to SHell Sort README.md
This commit is contained in:

committed by
Oleksii Trekhleb

parent
831ce89a45
commit
e53f5f909d
@ -9,6 +9,13 @@ are needed, which indicates that the list is sorted.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: worst _O_(_n_<sup>2</sup>), best _O_(_n_), average _O_(_n_<sup>2</sup>)
|
||||||
|
|
||||||
|
###### space: worst _O_(1) auxiliary
|
||||||
|
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- [Wikipedia](https://en.wikipedia.org/wiki/Bubble_sort)
|
- [Wikipedia](https://en.wikipedia.org/wiki/Bubble_sort)
|
||||||
|
@ -54,6 +54,12 @@ zero.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: worst _O_(_n_ + _k_), best _O_(_n_), average _O_(_n_ + _k_) where _n_ is the number of elements in the input array and _k_ is the range of the output.
|
||||||
|
|
||||||
|
###### space: worst _O_(_n_ + _k_)
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- [Wikipedia](https://en.wikipedia.org/wiki/Counting_sort)
|
- [Wikipedia](https://en.wikipedia.org/wiki/Counting_sort)
|
||||||
|
@ -13,6 +13,12 @@ rather than a linear-time search to find the maximum.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: worst _O_(_n log n_), best _O_(_n log n_), average _O_(_n log n_)
|
||||||
|
|
||||||
|
###### space: worst _O_(1) auxiliary
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
[Wikipedia](https://en.wikipedia.org/wiki/Heapsort)
|
[Wikipedia](https://en.wikipedia.org/wiki/Heapsort)
|
||||||
|
@ -10,6 +10,13 @@ sort.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: worst _O_(_n_<sup>2</sup>), best _O_(_n_), average _O_(_n_<sup>2</sup>)
|
||||||
|
|
||||||
|
###### space: worst _O_(1) auxiliary
|
||||||
|
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
[Wikipedia](https://en.wikipedia.org/wiki/Insertion_sort)
|
[Wikipedia](https://en.wikipedia.org/wiki/Insertion_sort)
|
||||||
|
@ -22,6 +22,12 @@ emulate merge sort (top-down).
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: average _O_(_n log n_)
|
||||||
|
|
||||||
|
###### space: worst _O_(_n_)
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- [Wikipedia](https://en.wikipedia.org/wiki/Merge_sort)
|
- [Wikipedia](https://en.wikipedia.org/wiki/Merge_sort)
|
||||||
|
@ -23,6 +23,12 @@ The horizontal lines are pivot values.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: worst _O_(_n_<sup>2</sup>), best _O_(_n log n_), average _O_(_n log n_)
|
||||||
|
|
||||||
|
###### space: worst _O_(_n_) auxiliary
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- [Wikipedia](https://en.wikipedia.org/wiki/Quicksort)
|
- [Wikipedia](https://en.wikipedia.org/wiki/Quicksort)
|
||||||
|
@ -25,6 +25,12 @@ comparison-based sorts (and worse if keys are much longer than `log n`).
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: worst _O_(_n_), best _O_(_n_), average _O_(_n_)
|
||||||
|
|
||||||
|
###### space: always _O_(_n_)
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
- [Wikipedia](https://en.wikipedia.org/wiki/Radix_sort)
|
- [Wikipedia](https://en.wikipedia.org/wiki/Radix_sort)
|
||||||
|
@ -13,6 +13,12 @@ memory is limited.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: worst _O_(_n_<sup>2</sup>), best _O_(_n_<sup>2</sup>), average _O_(_n_<sup>2</sup>)
|
||||||
|
|
||||||
|
###### space: _O_(1) auxiliary
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
[Wikipedia](https://en.wikipedia.org/wiki/Selection_sort)
|
[Wikipedia](https://en.wikipedia.org/wiki/Selection_sort)
|
||||||
|
@ -42,6 +42,12 @@ Shell sort uses insertion sort to sort the array.
|
|||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
## Complexity
|
||||||
|
|
||||||
|
###### time: best _O_(_n log n_), average - depends on 'gap sequence'.
|
||||||
|
|
||||||
|
###### space: worst _O_(_n_) total, _O_(1) auxiliary
|
||||||
|
|
||||||
## References
|
## References
|
||||||
|
|
||||||
* [Tutorials Point](https://www.tutorialspoint.com/data_structures_algorithms/shell_sort_algorithm.htm)
|
* [Tutorials Point](https://www.tutorialspoint.com/data_structures_algorithms/shell_sort_algorithm.htm)
|
||||||
|
Reference in New Issue
Block a user