Question

The Sedgewick's Gap Sequence can be calculated with 4*9^i-9*2^i+1 and 4^i-3*2^i+1. What is the value of "i"?

Was it helpful?

Solution

To perform a shellsort, you compute the gap sequence, sometimes called the increment sequence, using i starting at 1 and incrementing it until it's large enough to sensibly start sorting (Sedgewick suggests that when you get the largest gap sequence less than N/3).

Then you shellsort starting with the largest gap down to 1.

Note: the gap sequence equations you posted don't seem to agree with what's on Wikipedia's shellsort page and don't seem to work. You might want to verify the equations you want to use.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top