RosettaCodeData/Task/Sorting-algorithms-Shell-sort/00DESCRIPTION

20 lines
995 B
Text
Raw Permalink Normal View History

2013-04-11 01:07:29 -07:00
{{Sorting Algorithm}}
2016-12-05 22:15:40 +01:00
;Task:
Sort an array of elements using the [[wp:Shell sort|Shell sort]] algorithm, a diminishing increment sort.
The Shell sort   (also known as Shellsort or Shell's method)   is named after its inventor, Donald Shell, who published the algorithm in 1959.
Shell sort is a sequence of interleaved insertion sorts based on an increment sequence.
2015-02-20 00:35:01 -05:00
The increment size is reduced after each pass until the increment size is 1.
2016-12-05 22:15:40 +01:00
2015-02-20 00:35:01 -05:00
With an increment size of 1, the sort is a basic insertion sort, but by this time the data is guaranteed to be almost sorted, which is insertion sort's "best case".
2016-12-05 22:15:40 +01:00
Any sequence will sort the data as long as it ends in 1, but some work better than others.
Empirical studies have shown a geometric increment sequence with a ratio of about 2.2 work well in practice.
[http://www.cs.princeton.edu/~rs/shell/]
Other good sequences are found at the [https://oeis.org/search?q=shell+sort On-Line Encyclopedia of Integer Sequences].
<br><br>