sorter.c
static void shellSort(int* array, int length)
{
    int gapCount = 0;
    while(gapCount< SHELL_INC_TOTAL)
    {
        int gap = shellIncrements[gapCount];
        int i=0;
        int j=0;
        for(i=gap;i<length;i++)
        {
            int key = array[i];
            j=i-gap;
            while((j>=0) && (array[j]>key))
            {
                array[j+gap] = array[j];
                j-= gap;
            }
            array[j+gap] = key;
        }
        gapCount++;
    }
}
/**
 * If an array is k-sorted and then j-sorted it remains k-sorted
 * Idea is bring in order far apart elements faster than something like insertion sort
 * For eg: first 7 sort, then 4 sort, then 1 sort
 * Constants defined are important. Using Sedgewick's values here
 * Compared to insertion sort, number of swaps measured to be much lower
 */
If an array is k-sorted and then j-sorted it remains k-sorted
Idea is bring in order far apart elements faster than something like insertion sort
For eg: first 7 sort, then 4 sort, then 1 sort
Constants defined are important. Using Sedgewick's values here
Compared to insertion sort, number of swaps measured to be much lower
If an array is k - sorted and then j - sorted it remains k - sorted Idea is bring in order far apart elements faster than something like insertion sort For eg : first 7 sort then 4 sort then 1 sort Constants defined are important . Using Sedgewick ' s values here Compared to insertion sort number of swaps measured to be much lower
static void shellSort(int* array, int length)
{
    int gapCount = 0;
    while(gapCount< SHELL_INC_TOTAL)
    {
        int gap = shellIncrements[gapCount];
        int i=0;
        int j=0;
        for(i=gap;i<length;i++)
        {
            int key = array[i];
            j=i-gap;
            while((j>=0) && (array[j]>key))
            {
                array[j+gap] = array[j];
                j-= gap;
            }
            array[j+gap] = key;
        }
        gapCount++;
    }
}
static void shellSort ( int * array , int length ) { int gapCount = 0 ; while ( gapCount < SHELL_INC_TOTAL ) { int gap = shellIncrements [ gapCount ] ; int i = 0 ; int j = 0 ; for ( i = gap ; i < length ; i ++ ) { int key = array [ i ] ; j = i - gap ; while ( ( j >= 0 ) && ( array [ j ] > key ) ) { array [ j + gap ] = array [ j ] ; j -= gap ; } array [ j + gap ] = key ; } gapCount ++ ; } }
If an array is k-sorted and then j-sorted it remains k-sorted
 Idea is bring in order far apart elements faster than something like insertion sort
 For eg: first 7 sort, then 4 sort, then 1 sort
 Constants defined are important.
If an array is k - sorted and then j - sorted it remains k - sorted Idea is bring in order far apart elements faster than something like insertion sort For eg : first 7 sort then 4 sort then 1 sort Constants defined are important .