template <typename T> void ShellSort(T* A,int n) { int i = 0,j = 0,increament = 0; T tmp; for (increament = n/2;increament >= 1;increament /= 2) { for (i = increament;i < n;i++) { tmp = a[i]; for (j = i;j >= increament;j -= increament) { if (a[j-increament] > tmp] a[j] = a[j-increament]; else break; } a[j] = tmp; } } } 此种增量情况下,算法复杂度为Θ(n*n) 当增量为1,3,7,...,2k-1时,算法复杂度为Θ(n3/2)