/*
缩小增量排序:SHEEL'S SORT
时间复杂度:不超过O(n^2)
空间复杂度:O(1)
稳定性:不稳定
ascend
TIME: 2017年10月16日 14:29:52
*/
void shell_sort(int array[],int array_length)
{
int step=array_length/2;
while(step)
{
int j=0;
for(int j=step;i<array_length;i++)
{
if(array[i-step]>array[i])
{
int temp=array[i];
for(j=i-step;j>=0&&array[j]>temp;j-=step)
{
array[j+step]=array[j];
}
array[j+step]=temp;
}
}
step/=2;
}
}
缩小增量排序:SHEEL'S SORT
时间复杂度:不超过O(n^2)
空间复杂度:O(1)
稳定性:不稳定
ascend
TIME: 2017年10月16日 14:29:52
*/
void shell_sort(int array[],int array_length)
{
int step=array_length/2;
while(step)
{
int j=0;
for(int j=step;i<array_length;i++)
{
if(array[i-step]>array[i])
{
int temp=array[i];
for(j=i-step;j>=0&&array[j]>temp;j-=step)
{
array[j+step]=array[j];
}
array[j+step]=temp;
}
}
step/=2;
}
}