[Basic algorithm] sorting

Source: Internet
Author: User
  • Stability, internal and external storage, ordered area, unordered Area

Stability (personal understanding): The original relative positions of the same number remain unchanged, which means stability.

  Average time complexity Worst time complexity Auxiliary space (space complexity) Stable? Best time complexity    
Select sort       Unstable      
Hill sorting       Unstable      
Heap sorting       Unstable      
Fast sorting N * log (N) N2 A stack space is required for recursion.
The worst is N, which can be log (n)
Unstable      
               
Bubble N2 N2 O (1) Stability N (N-1 times comparison)    
Cocktail (two-way bubble)       Stability      
Merge       Stability      
Binary Tree sorting       Stability      
Insert       Stability      
               
               
  • Basic operation: Compare the keyword size

Change the pointer to the record or move the record itself

  • Common storage methods for objects to be sorted: sequential tables (such as arrays), linked lists,

 

[Basic algorithm] sorting

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.