Common sorting algorithm (a) - Overview

Sorting Algorithm Description

0.1  ordering definition

  A sequence of objects are ordered according to a keyword.

0.2 Terminology

  • Stability : b if a is originally in the front, and a = b, a b of the front still after sorting;
  • Unstable : If after a front b of the original, and a = b, a sorting may occur at the back of b;
  • The sort : Sort all operations are done in memory;
  • External sorting : Since the data is too large, and therefore the data on the disk, and disk and memory sorting through the data transfer can be;
  • Time complexity:  an algorithm execution time taken.
  • Space complexity : End of a desired size to run memory-intensive programs.

0.3 Algorithm summary

Picture Glossary:

  • n: the size of data
  • The number of "buckets" of: k
  • In-place: constant memory occupy, without occupying additional memory
  • Out-place: uses extra memory

0.4 Classification Algorithm

0.5 Comparison of the differences between the non-

  Common quick sort, merge sort, heap sort, bubble sort , etc. to compare the sort . In the final result of the sorting, the order between the elements depends on the comparison therebetween. Each number must be compared with other number, in order to determine their position.
  In the bubble sort sort of class, as the problem size n, and because the need to compare n times, the average time complexity is O (n²). In merge sort, quick sort sort of class, the scale of the problem by divide and conquer reduction is logN times, so the average time complexity O (nlogn) .
  Compare Sort advantage is applied to the data of all sizes, but also do not care about the distribution of data, it can be sorted. It can be said, comparing the situation to sort suitable for all needs sorting.

  Counting sequencing, radix sort, bucket sort belong to the non-sorted comparison . Non-comparative sort through before determining each element, how many elements should be sorted. For array ARR, calculated arr [i] until the number of elements, is uniquely determined arr [i] position in the sorted array.
  Comparison of ordering non-existing number of elements can be determined for each element before long, all the time traversal can be solved. Time complexity of O (n-) .
  Comparison of Non-sort time complexity bottom, but the non-sorted comparison space required to determine a unique position. So there are certain requirements for data size and data distribution.

Guess you like

Origin www.cnblogs.com/FondWang/p/12575469.html