Shell sort algorithm

  Operation performing:
   
        
Comparisons done:
Elements moved:
Legend:
28 - elements of the original array
13 - sub-array currently being sorted
13 - each shade of fuscia represents a sort of a given sub-array
20 - yet untached elements

The shell sort algorithm, named after its inventor Donald Shell, works as follows.

Q: How do we decide what increment sequence to use?
So far no provably best sequence has been found. Many sequences have been studied in literature, and some have been found that work well in practice. In practice, we generally use sequences that decrease roughly geometrically, so the number of increments is logarithmic in the size of the file. The practical effect of finding a good increment sequence is limited to perhaps a 25% speedup. Here are several increment sequences: