@@ -36,6 +36,7 @@ $ pip install py-algorithms
3636 - Binary Search
3737
3838 ^ Sorting
39+ - Shell Sort (Shell method)
3940 - Heap Sort (Fibonacci heap)
4041 - Merge Sort
4142 - Bubble Sort
@@ -120,6 +121,7 @@ sorting_algorithm(xs)
120121
121122# => [-1, 0, 4, 5, 6, 7, 8, 9, 12]
122123```
124+
123125#### * Heap Sort (https://en.wikipedia.org/wiki/Heapsort)
124126
125127In computer science, heapsort is a comparison-based sorting algorithm.
@@ -143,6 +145,33 @@ sorting_algorithm(xs)
143145
144146# => [-1, 0, 4, 5, 6, 7, 8, 9, 12]
145147```
148+
149+ #### * Shell Sort (https://en.wikipedia.org/wiki/Shellsort)
150+
151+ Shellsort, also known as Shell sort or Shell's method, is an in-place comparison sort.
152+ It can be seen as either a generalization of sorting by exchange (bubble sort) or
153+ sorting by insertion (insertion sort). The method starts by sorting pairs of elements far apart
154+ from each other, then progressively reducing the gap between elements to be compared.
155+ Starting with far apart elements, it can move some out-of-place elements into position faster
156+ than a simple nearest neighbor exchange. Donald Shell published the first version of this sort in 1959
157+ The running time of Shellsort is heavily dependent on the gap sequence it uses. For many practical variants,
158+ determining their time complexity remains an open problem.
159+
160+ Worst case: О(n^2)
161+ Best case: О(n log n)
162+ Average: ~
163+ Worst case space: O(n)
164+
165+ ``` python
166+ from py_algorithms.sort import new_shell_sort
167+
168+ xs = [0 , 6 , 7 , 8 , 9 , 4 , 5 , 12 , - 1 ]
169+ sorting_algorithm = new_shell_sort()
170+ sorting_algorithm(xs)
171+
172+ # => [-1, 0, 4, 5, 6, 7, 8, 9, 12]
173+ ```
174+
146175---
147176
148177### Search Algorithms
0 commit comments