What would be a good hash function to sort the bucket?

Firstly, most places that claim to have implementation bucket sortare actually implementing counting sort. My question is how bucket sortit is implemented on Geek Viewpoint and Wikipedia . I really don't get / as a hash function on Geek Viewpoint, and I don't get it on Wikipedia. Can someone explain a simpler method to create a good hash function to sort the bucket? Something the average person can understand and remember.

+4
source share
1 answer

I would not think that there is a universally good hash function that catch bucket sorting. A hash is good if it produces roughly the same size buckets, but this obviously depends on the distribution of the sorted values. That's why bucket sorting works so well when you have a priori knowledge of distribution, for example, when you have to sort people’s records by their height.

Also, the worst case of sorting in a beech is not , as the Geekview link erroneously suggests. The worst case (in terms of time complexity) is when all the elements are in the same bucket.

, , - , h(x) = x. , , , , , .

+2

Source: https://habr.com/ru/post/1598762/


All Articles