First, the algorithm thought
Recording the entire first row of the sequence to be divided into several sub-sequences, respectively direct insertion sort, when "basically in order" to be recorded throughout the sequence, and then once for all records direct insertion sort.
Tip: subsequence is not simply constitute a "paragraph by paragraph split", but a record will be separated by increments dk composed of a sequence, so that the increment dk trip by shortening (for example in order to take 5,3,1) until dk = 1 so far.
Second, the algorithm process
In the first pass, for example, which is a subsequence {49,13} {} {65,49 38,27 97,55 *} {} {76,04}
Third, Performance Analysis
(1) Time Complexity Analysis
- The worst time complexity is O (n ^ 2)
- The best time complexity is O (n)
- The average time complexity is O (n ^ 1.25)
Complexity (2) Spatial Analysis
Algorithm requires an auxiliary storage space does not change with changes in the size of a column to be sorted, is a constant, so the space complexity is O (1)
(3) Stability
Since the re-divided into multiple sub combinations of the time series, each ordered sequence formed from the main sequence, which sequence elements so that the main sequence changed, so that the algorithm is unstable. (* 49 described later was sorted to the front 49)