From 619c58ec87475aa166331b307aceaf57d7c3e08f Mon Sep 17 00:00:00 2001 From: Oleksii Trekhleb Date: Fri, 22 Jun 2018 15:34:32 +0300 Subject: [PATCH] Update READMEs. --- src/algorithms/sorting/bubble-sort/README.md | 13 +++---------- src/algorithms/sorting/counting-sort/README.md | 6 +++--- src/algorithms/sorting/heap-sort/README.md | 6 +++--- src/algorithms/sorting/insertion-sort/README.md | 7 +++---- src/algorithms/sorting/merge-sort/README.md | 6 +++--- src/algorithms/sorting/quick-sort/README.md | 6 +++--- src/algorithms/sorting/radix-sort/README.md | 6 +++--- src/algorithms/sorting/selection-sort/README.md | 6 +++--- src/algorithms/sorting/shell-sort/README.md | 6 +++--- 9 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/algorithms/sorting/bubble-sort/README.md b/src/algorithms/sorting/bubble-sort/README.md index 43610be7..aed71696 100644 --- a/src/algorithms/sorting/bubble-sort/README.md +++ b/src/algorithms/sorting/bubble-sort/README.md @@ -11,16 +11,9 @@ are needed, which indicates that the list is sorted. ## Complexity -Time - -- worst _O_(_n_2), -- best _O_(_n_), -- average _O_(_n_2) - -Space - -worst _O_(1) auxiliary - +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Bubble sort** | n | n2 | n2 | 1 | Yes | | ## References diff --git a/src/algorithms/sorting/counting-sort/README.md b/src/algorithms/sorting/counting-sort/README.md index d210f32d..098961a0 100644 --- a/src/algorithms/sorting/counting-sort/README.md +++ b/src/algorithms/sorting/counting-sort/README.md @@ -56,9 +56,9 @@ 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_) +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Counting sort** | n + r | n + r | n + r | n + r | Yes | r - biggest number in array | ## References diff --git a/src/algorithms/sorting/heap-sort/README.md b/src/algorithms/sorting/heap-sort/README.md index 9c402d56..6ccc50b3 100644 --- a/src/algorithms/sorting/heap-sort/README.md +++ b/src/algorithms/sorting/heap-sort/README.md @@ -15,9 +15,9 @@ 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 +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Heap sort** | n log(n) | n log(n) | n log(n) | 1 | No | | ## References diff --git a/src/algorithms/sorting/insertion-sort/README.md b/src/algorithms/sorting/insertion-sort/README.md index 3f59f5ab..cd3a74ef 100644 --- a/src/algorithms/sorting/insertion-sort/README.md +++ b/src/algorithms/sorting/insertion-sort/README.md @@ -12,10 +12,9 @@ sort. ## Complexity -###### time: worst _O_(_n_2), best _O_(_n_), average _O_(_n_2) - -###### space: worst _O_(1) auxiliary - +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Insertion sort** | n | n2 | n2 | 1 | Yes | | ## References diff --git a/src/algorithms/sorting/merge-sort/README.md b/src/algorithms/sorting/merge-sort/README.md index e015b058..f4ed837a 100644 --- a/src/algorithms/sorting/merge-sort/README.md +++ b/src/algorithms/sorting/merge-sort/README.md @@ -24,9 +24,9 @@ emulate merge sort (top-down). ## Complexity -###### time: average _O_(_n log n_) - -###### space: worst _O_(_n_) +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Merge sort** | n log(n) | n log(n) | n log(n) | n | Yes | | ## References diff --git a/src/algorithms/sorting/quick-sort/README.md b/src/algorithms/sorting/quick-sort/README.md index 50b63931..683a7f3f 100644 --- a/src/algorithms/sorting/quick-sort/README.md +++ b/src/algorithms/sorting/quick-sort/README.md @@ -25,9 +25,9 @@ The horizontal lines are pivot values. ## Complexity -###### time: worst _O_(_n_2), best _O_(_n log n_), average _O_(_n log n_) - -###### space: worst _O_(_n_) auxiliary +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Quick sort** | n log(n) | n log(n) | n2 | log(n) | No | | ## References diff --git a/src/algorithms/sorting/radix-sort/README.md b/src/algorithms/sorting/radix-sort/README.md index 90920fe3..1d1fab18 100644 --- a/src/algorithms/sorting/radix-sort/README.md +++ b/src/algorithms/sorting/radix-sort/README.md @@ -27,9 +27,9 @@ 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_) +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Radix sort** | n * k | n * k | n * k | n + k | Yes | k - length of longest key | ## References diff --git a/src/algorithms/sorting/selection-sort/README.md b/src/algorithms/sorting/selection-sort/README.md index cc1fbeec..6a708d25 100644 --- a/src/algorithms/sorting/selection-sort/README.md +++ b/src/algorithms/sorting/selection-sort/README.md @@ -15,9 +15,9 @@ memory is limited. ## Complexity -###### time: worst _O_(_n_2), best _O_(_n_2), average _O_(_n_2) - -###### space: _O_(1) auxiliary +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Selection sort** | n2 | n2 | n2 | 1 | No | | ## References diff --git a/src/algorithms/sorting/shell-sort/README.md b/src/algorithms/sorting/shell-sort/README.md index 3837ecbc..5030333f 100644 --- a/src/algorithms/sorting/shell-sort/README.md +++ b/src/algorithms/sorting/shell-sort/README.md @@ -44,9 +44,9 @@ 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 +| Name | Best | Average | Worst | Memory | Stable | Comments | +| --------------------- | :-------------: | :-----------------: | :-----------------: | :-------: | :-------: | :-------- | +| **Shell sort** | n log(n) | depends on gap sequence | n (log(n))2 | 1 | No | | ## References