Article directory
Hill sort
Hill sort is an optimized sorting algorithm for direct insertion sort
Hill sort is also known as "shrinking incremental sort"
Let's look at a picture rendering
Are you a little confused? Let's look at a piece of thinking that others have summarized.
Looking at it now, is it a bit of a clue, but it still seems a bit strange.
By looking at ideas: Summed up: first determine the length, then divide by 2 to see how many groups can be divided into, and then group according to the initial unordered array, pay attention to sorting after placing in one group, use the direct insertion sorting algorithm
4 and 2 are divided into a group, and then let 2 replace the position of 4, and 4 replace the position of 2 to achieve order.