Time complexity analysis of various sorts of 24 functions

24 functions of various sorting time complexity analysis

1 Stable sorting
1) Bubbling
Insert picture description here

2) Insert
Insert picture description here

3) Merge
Insert picture description here

Insert picture description here
Insert picture description here

2 Unstable sorting
1) Selection sorting
Insert picture description here

2) Hill sort
Insert picture description here

3) Quick sort
Refer to quick sort analysis

4) Heap sorting
Refer to add link description

3 Finally, a summary table of various sorting O(N) and the use occasions of sorting are given
1) bubbling, selection, insertion, priority selection insertion. Because the O(N) of bubbling and selection is N^2, the best case of insertion cannot be achieved, and insertion is a stable sort.
2) When the data is ordered, it is very efficient to use insertion and Hill sorting;
3) When merging files, choose merge sorting. Of course, using heap sorting is not a big problem, because sometimes it is difficult to compare their specific efficiency , Well instability.
4) Fast sorting is an efficient sorting. When the sentinels fetched each time just divide the array equally, the efficiency is the best. Under normal circumstances, it is a good choice to use fast sorting.
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44517656/article/details/108032711