Shellsort

First move distant values closer to their final positions.

The gap starts at half the length, rounded down, and halves after each pass.

With a gap of 3, positions 1, 4 and 7 form one insertion chain. A final gap of 1 sorts the entire array.

These gaps take O(n²) time in the worst case and O(1) extra space. Equal keys can change order.