void ShellSort (int array[], int num)
{
int inc = num/2;
while (inc > 0)
{
for (int i=inc; i < num-1; i++)
{
int temp = array[i];
int j=i;
while (j>= inc && temp < array [j-inc])
{
array[j] = array[j-inc];
j -= inc;
}
array [j] = temp;
}
inc = inc/2.2; // note the subdivision value which could be 2, but 2.2 is better
}
}
No comments:
Post a Comment