C examples for Data Structure:Sort
sorts an int array into increasing order. This method is known as shellsort as it is invented by D. L. Shell in 1959:
void shellsort(int w[], int p) { int gap, j, k, temp; for(gap = p/2; gap > 0; gap /= 2) for(j = gap; j < p; j++) for(k = j - gap; k >= 0 && w[k] > w[k + gap]; k -= gap) { temp = w[k]; w[k] = w[k + gap]; w[k + gap] = temp; } }