Base sort
The previous algorithm has a PR feature, which is based on the comparison size to sort. Worst case Nlogn, besides comparison, is doing something else.
Bucket sort
Let's say we have n students whose grades are integers between 0 and 100 (so there's a different score for m=101). How do I sort students by their grades in linear time ?
Build 101 Barrels
void int N) { count[] initialization; while (read 1 students ' grades grade) Insert the student into the list of Count[grade]; for (i=0; i<m; i++ ) { if (Count[i]) outputs the entire count[i] linked list;} }
The complexity of Time is
What if M "n"? Below
Base sort
Base sort is an upgraded version of bucket ordering
If it is a bucket, you have to build 1001 barrels, but only 10 numbers, it's not worth it.
The binary cardinality is 2, the decimal base is 10, and the secondary bit is the first.
Set the number of elements is n, the integer into the B,LSD (secondary bit first) the number of times is P, then the worst time complexity is a total of p lying sort.
If the number of buckets is very small, then the complexity of time is the antecedent complexity.
Purpose of cardinality sorting, handling multi-keyword sorting
Sort multiple Keywords
The priority of the theme is not the second priority. Sub-priority does not need to be sorted at all. The second priority here is faster than the theme,
But is LSD faster than MSD at any time?
Data structure--sort (bottom)--base sort