Class sorting and selection exchange

Variety of sorting algorithms needed auxiliary space
1, all simple sorting methods (including: direct insertion, and select foaming) and heap sort space complexity is O (1);

2, quick sort is O (logn), auxiliary space required for the stack;

3, the most desired merge sort auxiliary space, the space complexity is O (n);

4, the chain needs to radix sort attached to head and tail queue pointers, the spatial complexity is O (rd).

5, direct insertion sort: comparing the least number of n-1 times; up to (n-1) (n + 2) / 2
moves the least number of 0; up to (n-1) (n + 4) / 2
using a secondary storage space It is a stable sort;

6, binary insertion sort: Comparison with the smallest number of times and most are n * log2n (where 2 is a bottom, with the lower side represents a),
mobile least number of 0, a maximum time complexity is O (n2); (n squared, the following so also shown);
use of an auxiliary storage, sorting is stable;

7, bubble sort: Comparison minimum: n-1 times and a maximum time complexity is expressed as o (n2);
moving the least number of 0, expressed as a maximum time complexity O (n2);
using a secondary storage space, stable sort;

8, a simple selection sort: how many points the number of comparison not, are n (n-1) / 2 ;
mobile least number is 0, a maximum of 3 (n-1);
the use of a secondary storage space, is stable sort;

9, quicksort: Comparative and moving frequency and the minimum time complexity is expressed as O (n * log2n);
most comparisons and moving frequency and time complexity is expressed as O (n2);
an auxiliary storage using a minimum of log2n, most n square; unstable sort;

10, heap sort: comparing the number of movements and no good or bad, are O (n * log2n);
using a secondary storage space is unstable sort;

11,2- path merge sort: comparing the number of movements and no good or bad, are O (n * log2n);
requires n auxiliary storage, sorting is stable;

Guess you like

Origin www.cnblogs.com/KeepZ/p/11873451.html