希尔排序
希尔排序是插入排序的扩展。希尔排序的一个特点是:子序列的构成不是简单的逐段分割,而是将相隔某个增量的记录组成一个子序列。希尔排序的一个关键是:其步长(也就是增量)的取法,通常认为步长序列中的数字互质很重要。 希尔排序的C/C++代码实现: void shell_insert(int sort_array[], int length, int h) { int i, j, temp; for (i = h; i < length; ++i) if (sort_array[i] < sort_array[i-h]) { temp = sort_array[i]; sort_array[i] = sort_array[i-h]; [...]
Read the rest of this entry »