Summary of internal sorting algorithm

Source: Internet
Author: User
Tags comparison sort

Internal sorting summary

This blog post we briefly summarize the various internal sorting methods.

Of the 10 sorting algorithms, the first 7 belong to the sort algorithm based on "comparison", it has been proved by decision tree that the time complexity of any sort algorithm based on comparison can not be better than O (N*logn). The following 3 are not based on comparisons, so you can achieve linear uptime.

Below we give a variety of sorting methods of time and space complexity of the table (for their own summary, there is a wrong place, I hope everyone corrected or added).

Back to the column page: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/

For a variety of sorts, give the following summary:

The following 3 kinds of sorting efficiency are extremely high, and only under certain conditions can be used, and need additional auxiliary space, if D or K is very large, its performance for main memory ordering is not very good, count sort and cardinal order is most suitable for n very large, and K and D very small situation. In the comparison based sorting method, the fast sorting is best in terms of average performance. For the most common internal sorting application, the preferred method is not the insertion sort, and the hill sort is the quick sort. Merge sorting is generally used only on small or very near-ranked input data, because O (n) of the auxiliary space is required, so its performance is not as good as the main memory ordering, but the central idea of the external ordering when merging. Heap sorting is slower than Hill sort, although it is an O (N*LOGN) algorithm with a remarkably compact inner loop. Some of the better performance based on the internal ranking, only the merge sort is stable, fast sorting, heap sorting and hill sort are not stable, and other simple sorting algorithm is basically stable, except the selection of sorting. In general, for comparison based sorting methods, the sort is stable if the comparison is between adjacent two elements.

SOURCE Package Download

Source code includes: Bubble sort, select sort, insert sort, hill sort, heap sort, merge sort, fast sort, count sort, cardinal sort, etc., do not realize bucket sort.

Full Source package download address: http://download.csdn.net/detail/mmc_maodun/6995321

Author: csdn Blog Lan pavilion Wind and Rain

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.