Generic bucket sort The most common variant of bucket sort operates on a list of
n numeric inputs between zero and some maximum value
M and divides the value range into
b buckets each of size
M/
b. If each bucket is sorted using
insertion sort, the sort can be shown to run in expected linear time (where the average is taken over all possible inputs). However, the performance of this sort degrades with clustering; if many values occur close together, they will all fall into a single bucket and be sorted slowly. This performance degradation is avoided in the original bucket sort algorithm by assuming that the input is generated by a random process that distributes elements uniformly over the interval
[0,1).
ProxmapSort Similar to generic bucket sort as described above,
ProxmapSort works by dividing an array of keys into subarrays via the use of a "map key" function that preserves a partial ordering on the keys; as each key is added to its subarray, insertion sort is used to keep that subarray sorted, resulting in the entire array being in sorted order when ProxmapSort completes. ProxmapSort differs from bucket sorts in its use of the map key to place the data approximately where it belongs in sorted order, producing a "proxmap" — a proximity mapping — of the keys.
Histogram sort Another variant of bucket sort known as histogram sort or
counting sort adds an initial pass that counts the number of elements that will fall into each bucket using a count array. Using this information, the array values can be arranged into a sequence of buckets in-place by a sequence of exchanges, leaving no space overhead for bucket storage.
Postman's sort The '''Postman's sort'
is a variant of bucket sort that takes advantage of a hierarchical structure of elements, typically described by a set of attributes. This is the algorithm used by letter-sorting machines in post offices: mail is sorted first between domestic and international; then by state, province or territory; then by destination post office; then by routes, etc. Since keys are not compared against each other, sorting time is O(cn
), where c'' depends on the size of the key and number of buckets. This is similar to a
radix sort that works "top down," or "most significant digit first."
Shuffle sort The
shuffle sort is a variant of bucket sort that begins by removing the first 1/8 of the
n items to be sorted, sorts them recursively, and puts them in an array. This creates
n/8 "buckets" to which the remaining 7/8 of the items are distributed. Each "bucket" is then sorted, and the "buckets" are concatenated into a sorted array. ==Comparison with other sorting algorithms==