C语言常用排序方法大全(国外英语资料)
C语言常用排序方法大全(国外英语资料)
C language commonly used sorting method Daquan
*
=============================================================================
Related knowledge (all definitions are intended only to help readers understand relevant concepts, not strictly defined):
1, stable sorting and unstable sorting
Simply put, all equal numbers can still keep their relative order before they are sorted by some sort of sorting method
This sort of sorting method is stable. On the other hand, it is unstable.
For example: a set of numbers sorted before A1, A2, A3, A4, A5,, where a2=a4, after some sort of A1, A2, A4, A3, a5,
We say that this sort of ordering is stable, because the A2 is sorted before A4, and after sorting, it is still in front of a4. If it becomes A1, a4,
A2, A3, A5 aren't stable anymore.
2, internal sorting and external sorting
In the sorting process, all the numbers that need to be sorted are in memory, and their storage order is adjusted in memory, called intra sorting;
In the sorting process, only part of the number is transferred to memory, and the memory adjustment in the file memory storing order sorting method called external sorting.
3, the time complexity and space complexity of the algorithm
The time complexity of the algorithm refers to the amount of computation required to perform the algorithm.
The spatial complexity of an algorithm, in general, refers to the memory space needed to perform this algorithm.
================================================================================
* /
*
================================================
Function: select sort
Input: the name of the array (that is, the initial address of the array) and the number of elements in the array
================================================
* /
*
====================================================
The algorithm idea is described simply:
In a set of numbers to be sorted, the minimum number is chosen to be exchanged with the first position;
Then, in the remaining number,