From 98f2067fb78d7e53d5c5c25b967f25967df555e5 Mon Sep 17 00:00:00 2001 From: Viktor Lesyk Date: Sat, 14 Sep 2019 12:58:14 +0200 Subject: [PATCH] Fix --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2b58fb2..5b1088f 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Toolbox of software data structures, design patterns, algorithms and typical pro > Bubble sort, sometimes referred to as sinking sort, is a simple sorting algorithm that repeatedly steps through the list, compares adjacent elements and swaps them if they are in the wrong order. The pass through the list is repeated until the list is sorted. The algorithm, which is a comparison sort, is named for the way smaller or larger elements "bubble" to the top of the list. Although the algorithm is simple, it is too slow and impractical for most problems even when compared to insertion sort. Bubble sort can be practical if the input is in mostly sorted order with some out-of-order elements nearly in position. | Algorithm | Time Complexity | | | Space Complexity | +| | Best | Average | Worst | Worst | | ------------- |----------------:| -------:|----------:|-----------------:| | Bubble Sort | Θ(n) | Θ(n^2) | Θ(n^2) | Θ(1 ) | @@ -86,9 +87,10 @@ console.log(bubbleSort(numbers)); [Wikipedia says](https://en.wikipedia.org/wiki/Insertion_sort): > Insertion sort is a simple sorting algorithm that is relatively efficient for small lists and mostly sorted lists, and is often used as part of more sophisticated algorithms. It works by taking elements from the list one by one and inserting them in their correct position into a new sorted list similar to how we put money in out wallet. In arrays, the new list and the remaining elements can share the array's space, but insertion is expensive, requiring shifting all following elements over by one. Shellsort (see below) is a variant of insertion sort that is more efficient for larger lists. -| Algorithm | Time Complexity | | | Space Complexity | -| -------------- |----------------:| -------:|----------:|-----------------:| -| Insertion Sort | Ω(n) | Θ(n^2) | Θ(n^2) | Θ(1 ) | +| Algorithm | Time Complexity | | | Space Complexity | +| | Best | Average | Worst | Worst | +| -------------- |----------------:| --------:|----------:|-----------------:| +| Insertion Sort | Ω(n) | Θ(n^2) | Θ(n^2) | Θ(1 ) | ### Swift @@ -167,6 +169,7 @@ console.log(insertionSort(unsortedArray)); > The algorithm finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list. It does no more than n swaps, and thus is useful where swapping is very expensive. | Algorithm | Time Complexity | | | Space Complexity | +| | Best | Average | Worst | Worst | | -------------- |----------------:| -------:|----------:|-----------------:| | Selection sort | Ω(n^2) | Θ(n^2) | Θ(n^2) | Θ(1 ) |