From 0d75e8b9535f52261cd4df94de2a7e71ea08c3e2 Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:15:38 -0500 Subject: [PATCH 01/10] Added Complexity to Bubble Sort README.md --- src/algorithms/sorting/bubble-sort/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/algorithms/sorting/bubble-sort/README.md b/src/algorithms/sorting/bubble-sort/README.md index 4861dc2e4..83a05be8c 100644 --- a/src/algorithms/sorting/bubble-sort/README.md +++ b/src/algorithms/sorting/bubble-sort/README.md @@ -9,6 +9,13 @@ are needed, which indicates that the list is sorted. ![Algorithm Visualization](https://upload.wikimedia.org/wikipedia/commons/c/c8/Bubble-sort-example-300px.gif) +## Complexity + +###### time: worst _O_(n2), best _O_(n), average _O_(n2) + +###### space: worst _O_(1) auxiliary + + ## References - [Wikipedia](https://en.wikipedia.org/wiki/Bubble_sort) From b7b4e8b4e58f5b65192067decc1df104a308558b Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:28:40 -0500 Subject: [PATCH 02/10] Added Complexity to Counting-Sort README.md --- src/algorithms/sorting/counting-sort/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/sorting/counting-sort/README.md b/src/algorithms/sorting/counting-sort/README.md index 261efe521..d210f32d4 100644 --- a/src/algorithms/sorting/counting-sort/README.md +++ b/src/algorithms/sorting/counting-sort/README.md @@ -54,6 +54,12 @@ zero. ![Counting Sort](https://1.bp.blogspot.com/-xPqylngqASY/WLGq3p9n9vI/AAAAAAAAAHM/JHdtXAkJY8wYzDMBXxqarjmhpPhM0u8MACLcB/s1600/ResultArrayCS.gif) +## 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 - [Wikipedia](https://en.wikipedia.org/wiki/Counting_sort) From be2f60dfa5cb67f9a1365860e03c941748eb67d3 Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:30:20 -0500 Subject: [PATCH 03/10] Italicized n in Bubble Sort README.md --- src/algorithms/sorting/bubble-sort/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/algorithms/sorting/bubble-sort/README.md b/src/algorithms/sorting/bubble-sort/README.md index 83a05be8c..8d3c64d40 100644 --- a/src/algorithms/sorting/bubble-sort/README.md +++ b/src/algorithms/sorting/bubble-sort/README.md @@ -11,7 +11,7 @@ are needed, which indicates that the list is sorted. ## Complexity -###### time: worst _O_(n2), best _O_(n), average _O_(n2) +###### time: worst _O_(_n_2), best _O_(_n_), average _O_(_n_2) ###### space: worst _O_(1) auxiliary From 5f52182f057c0aa8acb7d3f55a3b9e26683ba208 Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:41:04 -0500 Subject: [PATCH 04/10] Added Complexity to Heap Sort README.md --- src/algorithms/sorting/heap-sort/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/sorting/heap-sort/README.md b/src/algorithms/sorting/heap-sort/README.md index 7504875df..9c402d566 100644 --- a/src/algorithms/sorting/heap-sort/README.md +++ b/src/algorithms/sorting/heap-sort/README.md @@ -13,6 +13,12 @@ rather than a linear-time search to find the maximum. ![Algorithm Visualization](https://upload.wikimedia.org/wikipedia/commons/4/4d/Heapsort-example.gif) +## Complexity + +###### time: worst _O_(_n log n_), best _O_(_n log n_), average _O_(_n log n_) + +###### space: worst _O_(1) auxiliary + ## References [Wikipedia](https://en.wikipedia.org/wiki/Heapsort) From 56d0aa5c2aeb1372e3892dbbf815230ceaf12c7b Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:44:22 -0500 Subject: [PATCH 05/10] Added Complexity to Insertion Sort README.md --- src/algorithms/sorting/insertion-sort/README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/algorithms/sorting/insertion-sort/README.md b/src/algorithms/sorting/insertion-sort/README.md index a31804d4f..3f59f5ab4 100644 --- a/src/algorithms/sorting/insertion-sort/README.md +++ b/src/algorithms/sorting/insertion-sort/README.md @@ -10,6 +10,13 @@ sort. ![Algorithm Visualization](https://upload.wikimedia.org/wikipedia/commons/0/0f/Insertion-sort-example-300px.gif) +## Complexity + +###### time: worst _O_(_n_2), best _O_(_n_), average _O_(_n_2) + +###### space: worst _O_(1) auxiliary + + ## References [Wikipedia](https://en.wikipedia.org/wiki/Insertion_sort) From 069e50e77e7ce129f116b79c52e610f2aebad849 Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:46:13 -0500 Subject: [PATCH 06/10] Added Complexity to Merge Sort README.md --- src/algorithms/sorting/merge-sort/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/sorting/merge-sort/README.md b/src/algorithms/sorting/merge-sort/README.md index 372cc2ac6..e015b0580 100644 --- a/src/algorithms/sorting/merge-sort/README.md +++ b/src/algorithms/sorting/merge-sort/README.md @@ -22,6 +22,12 @@ emulate merge sort (top-down). ![Merge Sort](https://upload.wikimedia.org/wikipedia/commons/e/e6/Merge_sort_algorithm_diagram.svg) +## Complexity + +###### time: average _O_(_n log n_) + +###### space: worst _O_(_n_) + ## References - [Wikipedia](https://en.wikipedia.org/wiki/Merge_sort) From 7233a27cfa50331d9b75aff52cec12c714fcd806 Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:48:02 -0500 Subject: [PATCH 07/10] Added Complexity to Quick Sort README.md --- src/algorithms/sorting/quick-sort/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/sorting/quick-sort/README.md b/src/algorithms/sorting/quick-sort/README.md index 3021e6e2d..50b639311 100644 --- a/src/algorithms/sorting/quick-sort/README.md +++ b/src/algorithms/sorting/quick-sort/README.md @@ -23,6 +23,12 @@ The horizontal lines are pivot values. ![Quicksort](https://upload.wikimedia.org/wikipedia/commons/6/6a/Sorting_quicksort_anim.gif) +## Complexity + +###### time: worst _O_(_n_2), best _O_(_n log n_), average _O_(_n log n_) + +###### space: worst _O_(_n_) auxiliary + ## References - [Wikipedia](https://en.wikipedia.org/wiki/Quicksort) From 75976bb2124817b93678e81bea5da055684b279b Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:49:31 -0500 Subject: [PATCH 08/10] Added Complexity to Radix Sort README.md --- src/algorithms/sorting/radix-sort/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/sorting/radix-sort/README.md b/src/algorithms/sorting/radix-sort/README.md index 01471cb3f..90920fe30 100644 --- a/src/algorithms/sorting/radix-sort/README.md +++ b/src/algorithms/sorting/radix-sort/README.md @@ -25,6 +25,12 @@ comparison-based sorts (and worse if keys are much longer than `log n`). ![Radix Sort](https://www.researchgate.net/publication/291086231/figure/fig1/AS:614214452404240@1523451545568/Simplistic-illustration-of-the-steps-performed-in-a-radix-sort-In-this-example-the.png) +## Complexity + +###### time: worst _O_(_n_), best _O_(_n_), average _O_(_n_) + +###### space: always _O_(_n_) + ## References - [Wikipedia](https://en.wikipedia.org/wiki/Radix_sort) From f7562eaca3a35e19a69a33379a98ca27ee567905 Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:51:08 -0500 Subject: [PATCH 09/10] Added Complexity to Selection Sort README.md --- src/algorithms/sorting/selection-sort/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/sorting/selection-sort/README.md b/src/algorithms/sorting/selection-sort/README.md index 7a16f205e..cc1fbeec0 100644 --- a/src/algorithms/sorting/selection-sort/README.md +++ b/src/algorithms/sorting/selection-sort/README.md @@ -13,6 +13,12 @@ memory is limited. ![Algorithm Visualization](https://upload.wikimedia.org/wikipedia/commons/9/94/Selection-Sort-Animation.gif) +## Complexity + +###### time: worst _O_(_n_2), best _O_(_n_2), average _O_(_n_2) + +###### space: _O_(1) auxiliary + ## References [Wikipedia](https://en.wikipedia.org/wiki/Selection_sort) From fbca13beb7c75920c31bce319673a59985c31a79 Mon Sep 17 00:00:00 2001 From: "Amjad Ali (MJ)" Date: Wed, 20 Jun 2018 01:56:20 -0500 Subject: [PATCH 10/10] Added Complexity to SHell Sort README.md --- src/algorithms/sorting/shell-sort/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/algorithms/sorting/shell-sort/README.md b/src/algorithms/sorting/shell-sort/README.md index 9d202c55e..3837ecbc2 100644 --- a/src/algorithms/sorting/shell-sort/README.md +++ b/src/algorithms/sorting/shell-sort/README.md @@ -42,6 +42,12 @@ Shell sort uses insertion sort to sort the array. ![Shellsort](https://www.tutorialspoint.com/data_structures_algorithms/images/shell_sort.jpg) +## Complexity + +###### time: best _O_(_n log n_), average - depends on 'gap sequence'. + +###### space: worst _O_(_n_) total, _O_(1) auxiliary + ## References * [Tutorials Point](https://www.tutorialspoint.com/data_structures_algorithms/shell_sort_algorithm.htm)