Home  >  Article  >  What are the general selection rules for sorting algorithms?

What are the general selection rules for sorting algorithms?

王林
王林Original
2020-05-12 13:38:157583browse

What are the general selection rules for sorting algorithms?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn