first, places claim have implementation of bucket sort implementing counting sort. question bucket sort implemented on geek viewpoint , wikipedia. don't get/like hash function on geek viewpoint , don't 1 on wikipedia. can explains simpler method creating hash function bucket sort? average person can understand , remember.
i wouldn't think there's universally hash function, that's catch of bucket sort. hash if produces equal size buckets, depends on distribution of values you're sorting. why bucket sort works when have priori knowledge of distribution, example when have sort records of people height.
furthermore, worst case of bucket sort isn't counting sort, geekview link erroneously suggests. worst case (regarding time complexity) when elements go same bucket.
and of course counting sort is kind of bucket sort, bucket sort hash h(x) = x. counting sort different once know buckets ever hold single value, don't need buckets store elements themselves, count.
Comments
Post a Comment