Various sorting methods and their comparison

Source: Internet
Author: User

1. Simple sorting

2. Tree selection sorting

Idea: Set the number of 221 groups in an array, the larger number (or smaller number) as the parent of the two numbers, and then build a complete binary tree. The root node of the tree is the maximum number. After outputting the number, the corresponding leaf node is replaced by negative infinity. The binary tree is then rebuilt on this basis until all nodes are negative infinity.

Complexity: The complexity of the first value is N, the complexity of the other values is log2 (n), and the average complexity is NLOG2 (n). (The complexity of the delete and insert operation of the binary tree is O (logk)?) )

Auxiliary space O (n).

3. Heap Sequencing

Various sorting methods and their comparison

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.