Hill sort (by Donald Shell):
Suppose you give an array that needs to be sorted and sort by 5-interval. The drawings are as follows
We slowly began to sort by the smaller intervals (and finally the interval was only 1).
Heap Sort:
First look at the insertion sort
voidSelection_sort (ElementType a[],intN) { for(i =0; i < N; i + +) {minposition= Scanformin (A, I, N –1 ); The corresponding is also a for loop without the best worst case.
So a sort algorithm is good or bad depends on the above to find the minimum number of good or bad
So how do we find the smallest dollar? Let's go out and talk. It occupies a place inside.
/*find the minimum element from a[i] to a[n–1] and assign its position to minposition*/Swap (A[i], a[minposition]); /*Place the smallest element of the unsorted part in the last position of the ordered part*/ }}
Did the arrow of the Radisson Press think of the heap sort ?
If we do this, we start a heap sort ....
voidHeap_sort (ElementType a[],intN) { for(i=n/2; i>=0; i--)/*Buildheap*/Percdown (A, I, N); for(i=n-1; I>0; i--) {Swap (&a[0], &a[i]);/*Deletemax*/Percdown (A,0, i); }}
Theorem: Heap sorting processing n the average number of random permutations of different elements is a random permutation of different elements with an average comparison of 2N Logn?? O (Nlog Logn) . Although heap ordering gives the best average time complexity, the actual effect is not as good as using heap ordering to give the best average time complexity, but the actual effect is not as good as the Sedgewick Delta sequence of hill sort.
Hill sort Heap Sort Merge sort