diff --git a/README.md b/README.md index 84f2bcf8..beeedeae 100644 --- a/README.md +++ b/README.md @@ -96,8 +96,9 @@ Source: [Big O Cheat Sheet](http://bigocheatsheet.com/). ![Big O of sorting algoritms](https://github.com/trekhleb/javascript-algorithms/blob/master/assets/big-o-sorting-algorithms.png) Source: [Big O Cheat Sheet](http://bigocheatsheet.com/). -| Name | Best | Average | Worst | Memory | Stable | Method | Notes | -| --------------------- | :-----: | :-------: | :-----: | :-------: | :-------: | :------------ | :-------------- | -| **Bubble sort** | n | n^2 | n^2 | 1 | Yes | Exchanging | Tiny code size | -| **Insertion sort** | n | n^2 | n^2 | 1 | Yes | Insertion | O(n + d), in the worst case over sequences that have d inversions | -| **Selection sort** | n^2 | n^2 | n^2 | 1 | No | Selection | Stable with O(n) extra space, for example using lists | +| Name | Best | Average | Worst | Memory | Stable | Method | Notes | +| --------------------- | :-------: | :-------: | :-------: | :-------: | :-------: | :------------ | :-------------- | +| **Bubble sort** | n | n^2 | n^2 | 1 | Yes | Exchanging | Tiny code size | +| **Insertion sort** | n | n^2 | n^2 | 1 | Yes | Insertion | O(n + d), in the worst case over sequences that have d inversions | +| **Selection sort** | n^2 | n^2 | n^2 | 1 | No | Selection | Stable with O(n) extra space, for example using lists | +| **Heap sort** | n log(n) | n log(n) | n log(n) | 1 | No | Selection | | diff --git a/src/algorithms/sorting/bubble-sort/README.md b/src/algorithms/sorting/bubble-sort/README.md index 68f75d4d..2c0f767b 100644 --- a/src/algorithms/sorting/bubble-sort/README.md +++ b/src/algorithms/sorting/bubble-sort/README.md @@ -8,3 +8,7 @@ The pass through the list is repeated until no swaps are needed, which indicates that the list is sorted. ![Algorithm Visualization](https://upload.wikimedia.org/wikipedia/commons/c/c8/Bubble-sort-example-300px.gif) + +## References + +[Wikipedia](https://en.wikipedia.org/wiki/Bubble_sort) diff --git a/src/algorithms/sorting/insertion-sort/README.md b/src/algorithms/sorting/insertion-sort/README.md index ed3a753f..a31804d4 100644 --- a/src/algorithms/sorting/insertion-sort/README.md +++ b/src/algorithms/sorting/insertion-sort/README.md @@ -10,3 +10,6 @@ sort. ![Algorithm Visualization](https://upload.wikimedia.org/wikipedia/commons/0/0f/Insertion-sort-example-300px.gif) +## References + +[Wikipedia](https://en.wikipedia.org/wiki/Insertion_sort) diff --git a/src/algorithms/sorting/selection-sort/README.md b/src/algorithms/sorting/selection-sort/README.md index e46a8fc6..7a16f205 100644 --- a/src/algorithms/sorting/selection-sort/README.md +++ b/src/algorithms/sorting/selection-sort/README.md @@ -12,3 +12,7 @@ memory is limited. ![Algorithm Visualization](https://upload.wikimedia.org/wikipedia/commons/b/b0/Selection_sort_animation.gif) ![Algorithm Visualization](https://upload.wikimedia.org/wikipedia/commons/9/94/Selection-Sort-Animation.gif) + +## References + +[Wikipedia](https://en.wikipedia.org/wiki/Selection_sort)