1. Definition of sorting: assume that the sequence Containing n records is {r1, r2 ,......, rn}, whose corresponding keywords are {k1, k2 ,......, kn}, must be determined 1, 2 ,......, an array of n: p1, p2 ,......, pn, so that the corresponding keyword meets kp1 <= kp2 <= ...... <= kpn non-incrementing or non-decreasing) relationship, even if the obtained sequence becomes a sequence ordered by keywords {rp1, rp2 ,......, rpn}, such an operation is called sorting.
2. Stability of sorting: Assuming the keyword ki = kj (I! = J), and the ri is ahead of rj in the sequence before sorting. If the ri is still ahead of rj after sorting, the sorting method used is stable. Otherwise, if rj leads the sorted sequence to ri, the method used is unstable. In short, Xiao Ming and Xiao Fang have the same total score. Xiao Ming ranks before Xiao Fang, while Xiao Ming also ranks before Xiao Fang. The Sorting Algorithm is stable, otherwise, the algorithm is unstable.
3. Inner sorting and external sorting: All records to be sorted are stored in the memory during the entire sorting process. External sorting is because the number of sorting records is too large and cannot be stored in the memory at the same time. The entire sorting process needs to exchange data multiple times between internal and external.
The internal sorting is mainly affected by three factors.
1) time performance. In the internal sorting, two types of operations are performed: Comparison and moving. In short, we should minimize the number of comparisons and minimize the number of moves in the sorting process.
2) auxiliary space. Space required to store the data to be sorted and other storage space required for Algorithm Execution.
3) Complexity of algorithms. This refers to the complexity of the algorithm itself, rather than the time complexity of the algorithm. Obviously, the algorithm is too complex and affects the sorting performance.
4. Classification of sorting algorithms
1) Exchange sorting: Bubble sorting and quick sorting.
2) Insert sorting: directly insert sorting, semi-insert sorting, and Hill sorting.
3) Select sorting: simple sorting and heap sorting.
4) Merge Sorting: Merge Sorting.
This article is from "Li Haichuan" blog, please be sure to keep this source http://lihaichuan.blog.51cto.com/498079/1282052