Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Lesyk committed Sep 14, 2019
1 parent 00ad2da commit 98f2067
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) |

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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 ) |

Expand Down

0 comments on commit 98f2067

Please sign in to comment.