Home > Common Problem > body text

What are the general selection rules for sorting algorithms?

王林
Release: 2020-05-12 13:38:15
Original
7597 people have browsed it

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!