School brother asked the question a data structure, on some sort of time complexity of the algorithm.
For approximate ordered sequence,
① When the direct insertion sort, which is a basic operation of moving elements in the array. At best, a column to be sorted ordered, without moving, in this time complexity is O (n),
when the ordered sequence is approximately, the number of basic operations is performed K times the maximum value and the current cycle, i.e., the time complexity is O (kn) since k is much smaller than n,
considering the direct insertion sort time complexity is O (n)
② When a bubble sort, bubble sort ordinary default, basic operation of comparison between the number of elements, so regardless
whether the order approximation, are time complexity O (n ^ 2)
③ When using simple ordering, the basic operation is independent of the comparison between the elements, and the state of the column to be sorted, i.e. the i-th
number of comparisons is Ni, time complexity is O (n ^ 2)
When the sum, if the current sequence is an ordered sequence of approximately, the most efficient direct insertion sort.