Hill sort Heap Sort Merge sort

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.