Skip to content

Commit 87d4d8d

Browse files
authored
feat(docs): add cocktail and comb sort docs (alexfertel#53)
1 parent 5e3780d commit 87d4d8d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/sorting/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ __Sources to read:__
5353
* [Geeksforgeeks](https://www.geeksforgeeks.org/bubble-sort/)
5454
* [Programiz](https://www.programiz.com/dsa/bubble-sort)
5555

56+
### [Cocktail_Shaker_Sort](./cocktail_shaker_sort.rs)
57+
58+
Cocktail Shaker Sort, also called bidirectional bubble sort, iterates through a list from top to bottom and then from bottom to top. It is highly performant when the items in the list are partially sorted. The complexity of any list is O(n^2), but it approaches O(n) if the distance of each item from its final position in the ordered list is relatively small.
59+
60+
__Sources to read:__
61+
* [Wikipedia](https://en.wikipedia.org/wiki/Cocktail_shaker_sort)
62+
* [Geeksforgeeks](https://www.geeksforgeeks.org/quick-sort/)
63+
* [Baeldung](https://www.baeldung.com/cs/cocktail-sort)
64+
65+
### [Comb_Sort](./comb_sort.rs)
66+
67+
Comb Sort is another optimization of Bubble Sort, and achieves this by eliminating small values towards the end of the list. It also uses a shrink-factor (k), which is used in the inner loop of Bubble Sort that performs the swapping of elements. The gap between elements that are compared in Bubble Sort is always 1, but the Comb Sort allows for the gap to be larger than 1 and then shrink by (k) for each iteration. (k) highly affects the efficiency of the algorithm, and is ideal at 1.3.
68+
69+
__Properties__
70+
* Best time Complexity : O(n)
71+
* Worst time Complexity: O(n^2)
72+
73+
__Sources to read:__
74+
* [Wikipedia](https://en.wikipedia.org/wiki/Comb_sort)
75+
* [Geeksforgeeks](https://www.geeksforgeeks.org/comb-sort/)
76+
* [javatpoint](https://www.javatpoint.com/comb-sort)
77+
78+
5679
### [Quick Sort](./quick_sort.rs)
5780

5881
QuickSort is a Divide and Conquer algorithm. It picks an element as a pivot and partitions the given array around the picked pivot. There are 4 common ways of selecting a pivot:
@@ -75,6 +98,7 @@ __Sources to read:__
7598
* [Geeksforgeeks](https://www.geeksforgeeks.org/quick-sort/)
7699
* [Mygreatlearning](https://www.mygreatlearning.com/blog/quick-sort-algorithm/)
77100

101+
78102
### [Selection Sort](./selection_sort.rs)
79103

80104
The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from the unsorted part and putting it at the beginning.

0 commit comments

Comments
 (0)