Keith Thompson wrote:
According to the Wikipedia article, the original Shell sort is
O(N**2),
I have observed that behavior, using e_driver.c at:
http://www.mindspring.com/~pfilandr/C/e_driver/
In the following output, s2sort represents the original Shellsort,
and the worst case is Distribution #2: card_shuffle,
with 131072 elements in the test array.
/* BEGIN e_driver.c program output */
Timing 5 different sorting functions.
Sorting arrays of N number of elements,
in 2 different distributions.
The elements are of type long unsigned.
sizeof (long unsigned) is 4.
The times shown are in seconds.
Distribution #1: Shuffled
N s2sort shsort spsort s3sort SI
131071 0.093000 0.078000 0.047000 0.062000 50.937000
131072 0.156000 0.079000 0.047000 0.063000 50.234000
Total times:
s2sort: 0.249000 e_type Shellsort, 1 / 2 increment ratio
shsort: 0.157000 e_type Shellsort, 7 / 16 increment ratio
spsort: 0.094000 e_type Shellsort, Sedgewick numbers
s3sort: 0.125000 e_type Shellsort, 3 / 7 increment ratio
SI: 101.171000 sisort, stable insertion sort
Distribution #2: card_shuffle
N s2sort shsort spsort s3sort SI
131071 0.062000 0.047000 0.031000 0.047000 7.110000
131072 6.828000 0.047000 0.032000 0.047000 7.203000
Total times:
s2sort: 6.890000 e_type Shellsort, 1 / 2 increment ratio
shsort: 0.094000 e_type Shellsort, 7 / 16 increment ratio
spsort: 0.063000 e_type Shellsort, Sedgewick numbers
s3sort: 0.094000 e_type Shellsort, 3 / 7 increment ratio
SI: 14.313000 sisort, stable insertion sort
/* END e_driver.c program output */