Algorithms and Data Structures [30 Days] Training Camp - Animations that Beginners Can Understand: The Principles and Codes of Hill Sorting (22)

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.

insert image description here
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

insert image description here4 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.

Guess you like

Origin blog.csdn.net/weixin_47723732/article/details/127474711