C language Hill (decreasing incremental) sort implementation source code and demo animation

C language Hill (decreasing incremental) sort implementation source code and demo animation

void shell_sort(int arr[], int len)
{
    int gap, tmp, i, j;

    for (gap = len; gap > 0; gap = gap)
        for (i = gap; i < len; i++) {
            tmp = arr[i];
            for (j = i - gap; j >= 0 && arr[j] > tmp; j -= gap) {
                arr[j + gap] = arr[j];
            }
            arr[j + gap] = tmp;
        }
    }
}
Demo animation


Comments

Popular posts from this blog

Python Receiving and parse JSON Data via UDP protocol

ubus lua client method and event registration code demo/example