1 希尔排序
在要排序的一组数中,根据某一增量分为若干子序列,并对子序列分别进行插入排序。
然后逐渐将增量减小,并重复上述过程。直至增量为1,此时数据序列基本有序,最后进行插入排序。
2 代码实现
#include <stdio.h>
void print(int* data, int len)
{
for (int i = 0; i < len; i++)
printf("%d\t", data[i]);
printf("\n");
}
void shellSort(int* data, int length)
{
if (NULL == data || length < 0)
{
printf("NULL == data or length < 0\n");
return;
}
int space = length >> 1;
while (space)
{
//总循环需要执行的个数