Sorting Algorithm Selection

The speed of insertion and bubble sorting is slow, but when the sequence participating in the sorting is partially or globally ordered, this sorting can achieve a faster speed.
Instead, in this case, quicksort is slow. When n is small, selection sort should be used when stability is not required, and insertion or bubble sort should be used when stability is required.
If the keywords of the records to be sorted are in a clearly limited range, and space allows, use bucket sorting.
When n is large, the keyword elements are relatively random, and quick sort is not required for stability.
When n is large, the keyword elements may appear in order. When stability is required, merge sort should be used when space allows.
When n is large, the key elements may appear in order, and heap sorting should be used when there is no requirement for stability.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325528251&siteId=291194637