The sorting algorithm (sorting algorithm) is an integral part of the computer algorithm. The sorting algorithm is to rearrange a sequence in order of size. Sorting is an old but still challenging question. Donald Knuth's classic book, the third volume of the Art of computer programming, Computer programming, is dedicated to discussing sorting and finding. From the point of disorder to order, from the angle of statistical physics, we can reduce the entropy of the system and increase the order of the system. The characteristic of order is a very useful priori knowledge about the system. Therefore, the sorting algorithm can be used as the basis of other fast algorithms, such as the binary method is based on ordered sequence search algorithm. Until today, the ranking algorithm is still one of the ways in which computer science is actively exploring.
Here I list some of the most common sorting methods and use the C language real
Is. The sequence is represented as an array of an, with an array of n elements. A[i] An element in an array, where I is the position (subscript) of the element in the set. In accordance with the provisions of C, array subscript starting from 0. Assuming that the array is arranged from left to right, the element labeled 0 is at the far left of the array.
The sequence is eventually arranged into a small to large order. The parameter AC in the following function is the number of elements in the array, that is, N.
(C-language array names to the pointer, passed to the function, so you need to pass the number of elements in the array AC to the function, see the "Expert C programming:deep C Secrets" book in detail)
Starting sequence (unsorted)
Ordered series (sorted)
Below the link, there are related algorithms animation legend, strongly recommended to read at the same time.
http://www.sorting-algorithms.com/