Home  >  Article  >  What is a sorting algorithm

What is a sorting algorithm

hzc
hzcOriginal
2020-07-03 17:24:1756484browse

The sorting algorithm refers to reordering one or more sets of data according to a predetermined pattern through specific algorithm factors. This new sequence follows certain rules and reflects certain laws. Therefore, after processing The resulting data is easy to filter and calculate, which greatly improves calculation efficiency.

What is a sorting algorithm

Recommended: "Dynamic diagram explanation of commonly used sorting algorithms""Four classic sorting algorithms in PHP

The so-called sorting algorithm refers to reordering one or more sets of data according to a predetermined pattern through specific algorithm factors. This new sequence follows certain rules and reflects certain patterns. Therefore, the processed data is easy to filter and calculate, which greatly improves calculation efficiency.

For sorting, we first require it to have a certain degree of stability, that is, when two identical elements appear in a sequence at the same time, after a certain sorting algorithm, the relative difference between the two before and after sorting The location does not change. In other words, even if there are two identical elements, they are different during the sorting process and are not allowed to be confused.

Sorting is an important operation in computer programming. Its function is to rearrange an arbitrary sequence of data elements (or records) into a keyword-ordered sequence.

Sort is to sort the elements in the collection together in a certain order. Generally speaking, there are two kinds of sorting, ascending order and descending order. There are 8 basic sorts in the algorithm:

(1) Bubble sorting;

(2) Selection sorting;

(3)Insertion sort;

(4)Hill sort;

(5)Merge sort;

(6)Quick sort;

(7) Radix sort;

(8) Heap sort;

(9) Counting sort;

(10) Bucket sort.

The above is the detailed content of What is a sorting algorithm. 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