hmmm,
Perhaps this link may answer your question. Not sure though.
http://www.answers.com/topic/shell-sort
/**
* Performs an insertion sort on elements of a[] with the given gap.
* If gap == 1, performs an ordinary insertion sort.
* If gap >= length, does nothing.
* Based on a C implementation from the article Insertion sort implementations
*/
#include <iostream>
using namespace std;
void shellSortPhase(int a[], size_t length, size_t gap) {
int i;
for (i = gap; i < length; ++i) {
int value = a[i];
int j;
for (j = i - gap; j >= 0 && a[j] > value; j -= gap) {
a[j + gap] = a[j];
}
a[j + gap] = value;
}
}
void shellSort(int a[], size_t length) {
/*
* gaps[] should approximate a geometric progression.
* The following gaps are every other Fibonacci number,
* which gives r=2.616.
*/
static const int gaps[] = {
1, 2, 5, 13, 34, 89, 233, 610, 1597, 4181, 10946
};
int sizeIndex;
for (sizeIndex = sizeof(gaps)/sizeof(gaps[0]) - 1;
sizeIndex >= 0;
--sizeIndex)
shellSortPhase(a, length, gaps[sizeIndex]);
}
int main()
{
int a[] = {7,34,6,3,2,7,8,12,3,5};
shellSort(a,10);
for(int i=0; i<10; i++)
{
cout<<a[i]<<" ";
}
cin.get();
return 0;
}