Sorting is sorted into inner and outer sort, depending on whether the band sort data is all put into memory.
The following is based on my experience of reading, the main analysis of the performance of the sorting.
Sort within: Insert sort (direct insert sort, hill Sort), select sort (Simple select sort, heap sort), swap sort (bubble sort, quick sort), merge sort.
More of them are insert sort, merge sort, quick sort.
Comparison of sorting algorithms: Performance comparisons can be analyzed in the following 5 ways: Time complexity (average, best, worst case), spatial complexity (auxiliary space), stability.
On average, three improved algorithms are better than hill sort, and are much better than three simple algorithms.
In the best case scenario, bubbling and direct insert sorting is better, meaning that four complex algorithms should not be used in cases where the sorted data is basically ordered.
Worst case perspective, heap Sorting and merge sorting are better.
The spatial complexity angle, the merge sort emphasizes to want to run fast, must give enough space; The fast sort also has the corresponding space complexity requirement; In contrast, the heap sorting space complexity position O (1), a small amount of demand, a lot of pay type. Therefore, when the algorithm execution environment is very concerned about memory usage, choosing heap sorting is a good choice, and merging sorting and quick sorting is not the best choice.
The stability angle, the merge sort is the champion. In the case of high algorithm stability, merge sort is the only choice.
The number of records to be sorted, the smaller the number of records, the more simple sorting should be selected. For example, when optimizing a quick sort, one aspect is that in cases where the number of records is less than a certain threshold, the insertion sort should be used.
The angle of the number of moves, simple selection of sorting advantage is very large.
Comparison of typical sorting algorithms