// From the software distribution accompanying the textbook // "A Practical Introduction to Data Structures and Algorithm Analysis, // Third Edition (C++)" by Clifford A. Shaffer. // Source code Copyright (C) 2007-2011 by Clifford A. Shaffer. // Shell Sort implementation and timing test driver #include "book.h" // Include comparator functions #include "compare.h" // Shell sort implementation // Modified version of Insertion Sort for varying increments template void inssort2(E A[], int n, int incr) { for (int i=incr; i=incr) && (Comp::prior(A[j], A[j-incr])); j-=incr) swap(A, j, j-incr); } template void shellsort(E A[], int n) { // Shellsort for (int i=n/2; i>2; i/=2) // For each increment for (int j=0; j(&A[j], n-j, i); inssort2(A, n, 1); } template void sort(E* array, int n) { shellsort(array, n); } #include "sortmain.cpp" int main(int argc, char** argv) { return sortmain(argc, argv); }