The general selection rules for various sorting algorithms are as follows:
(1) The number of elements n is large, the sorting code distribution is random, and there is no requirement for stability--- ------Quick sort
(2) The number of elements n is large, memory space allows, and stability is required-------------Two-way merge sort
(3) The number of elements n is large, the sorting code may be in positive or negative order, and stability is not required ---------Heap sort, two-way merge
(4) Elements The number n is small, the sorting code is basically ordered or random, and stability is required------------- Direct insertion sorting
(5) The number n of elements is small, and the stability is not Do the requirements------Direct selection sorting
(6) The number of elements n is small, and the sorting code is not close to the reverse order----Direct insertion sorting
(7) Bubble sorting Generally rarely use
The above is the detailed content of What are the general selection rules for sorting algorithms?. For more information, please follow other related articles on the PHP Chinese website!