Shell Sort
SortingavgO(n^1.5)worstO(n²)spaceO(1)
70
78
25
64
13
61
73
48
91
26
79
75
67
6
49
33
90
32
76
73
29
6
80
24
30
16
49
99
28
12
85
35
Start with 32 unsorted values
1 / 614
Size32
Distribution
Custom values2 to 150 whole numbers, each 1 to 999
seed 5
How it works
An insertion sort over interleaved sub-arrays: elements gap apart are sorted first, then the gap shrinks until it is 1. Early long-distance moves mean the final insertion-sort pass has very little left to do.
Complexity
- Best
- O(n log n)
- Average
- O(n^1.5)
- Worst
- O(n²)
- Space
- O(1)
- Stable
- No
- In place
- Yes