New Ket Net Algorithm Lesson series (b): sort

Source: Internet
Author: User
Tags comparison sorts

First, bubble sort
Each round adjacent position comparison, judge Exchange or not, find the wheel max/min, put to the corresponding position, the next round.
Second, choose the sort
Find the largest and smallest places at each time.
Third, insert sort
Each time you judge a number in front of all the worth of the size, find the right place, insert.
Iv. Merging and sorting
The most divided group, 22 merged, makes the group smaller and larger each time the merge is merged in the order of purpose. Key in group merge function (set flag for two groups, move flag bit to determine which number to enter new group)
V. Quick Sort
Randomly select a number, divided by the number of left and right groups. To the left and right two groups to do the above division.
Vi. sequencing of Heaps
The process of building the heap from the N/2 position forwards each person to the left and right children of the comparison and exchange. Swaps the top of the heap with the last value, out of the maximum value. Heap adjustment, from the top of the heap (at this point in case of non-conformance) has been switched down to greater than/less than the child node, the adjustment ends.
Vii. sort of Hill
Improved insertion and drainage
Insert a bit forward. Hill is instead a set step. The step size is lowered until the step is one.

Eight, barrel sorting
Count sort, base sort.

Complexity of Time:
123 N-Square
4567 N*logn
Eight N
Complexity of:
O (1): 12367
O (logn) -0 (N): Five
O (N) Four
O (M) eight (number of barrels)

Stability (the relative order of the same elements in the order of sorts is changed):
Stability: 1348
Instability: 2567

Why is the quick platoon called the Quick Platoon:
Not to say good, but in the best case, its progressive complexity is the same as the heap sort and merge sort, but the constant coefficient of fast sorting is relatively small.
The engineering sort is a comprehensive sort.
Small arrays, inserting rows
An array of large, fast, or O (n*logn) sorts.

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.