MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / ShellSort

Function ShellSort

CPP/sorting/shellsort.cpp:10–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8 * y = temp;
9}
10void ShellSort(int A[], int n) {
11 int gap, i, j, temp;
12 for (gap = n / 2; gap >= 1; gap /= 2) {
13 for (i = gap; i < n; i++) {
14 temp = A[i];
15 j = i - gap;
16 while (j >= 0 && A[j] > temp) {
17 A[j + gap] = A[j];
18 j = j - gap;
19 }
20 A[j + gap] = temp;
21 }
22 }
23}
24int main() {
25 int A[] = {11,13,7,12,16,9,24,5,10,3}, n = 10, i;
26 SellSort(A, n);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected