Shell Sort

Insertion sort with a shrinking gap. Each color outlines a stride-g subsequence; the final g=1 pass cleans up a near-sorted array.

Best: O(n log n) Avg: O(n^4/3 – n^3/2) Space: O(1) Not Stable
slow fast
Compare
Shift
Insert
Subseq 0
Subseq 1
Subseq 2
Subseq 3
Step
0/0
Pass
0
Gap
Compares
0
Shifts
0

Algorithm Trace

Press Start to run animation, or Step to advance one step at a time.