Algorithm-sort by selection
Excellent sorting algorithms include fast sorting and Hill sorting.Sorting is a preferred and most likely method. Because the selection of sorting is simple and clear, and the effect is obvious, when processing small-scale sorting, selecting sorting is a good choice.
1. Select to sort SelectSort ():Core: The smallest number is selected at the beginning of the constituency. Description: The smallest number 1 is the 4-switching position at the first position of the current constituency.When the selected area has only the last number, the sorting is complete. The following is the code for fast sorting:
The selection of sorting means that the minimum (of course the maximum) value can be selected each time to the front-end position of the number order. The entire number order is sorted.2. Time Complexity:The entire sorting needs to be compared n-1 times, respectively n-1, N-2... 1. So the time complexity O = (n-1) + (n-2) +... + 1 = O (n2 ).3. space complexity:An auxiliary space, so the space complexity is: O (1 ).