Can someone please provide a simple working sample of a shellsort in Java that uses the Knuth Sequence? I looked in several places over the internet but can't find an explanation that works well for me. I understand shellsort on a conceptual level - as it's an insertion sort that is done over a gap that shrinks over time until reaching a gap of 1 - which then is essentially an insertion sort. However the Knuth sequence is (k * 3 - 1)/2 and a list of the first few gaps is usually represented as [1, 4, 13, 40, 121.. and so on].
My question is how would this be implemented? Is the starting gap actually 1, or is it the value generated by this sequence just before it is greater than the size of the list being sorted? If the gap started at 1, the purpose would be defeated if I am understanding shell sort correctly. Could someone pelease shed some light on this? I feel like I've missed something critical for understanding this thing.
Thanks in advance.