Talk:Bucket sort

message: "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 n buckets each of size M/n" is a bit misleading IMO. Could the number of buckets be changed to b, so that n=number of elements matches the other sort pages? Neodymion (talk) 03:24, 22 June 2008 (UTC)
thread_title:  n=number of elements and also n=number of buckets 

message: While an example of an algorithm in source form is not a bad thing, in general pseudocode is preferable for a number of reasons. Wikipedia is not s source code repository, and once sample implementations start getting added people feel inclined to add more in their favourite language of choice. This ends up swamping articles on algorithms with an inordinate amount of source code that usually adds nothing not already provided by the pseudocode example. The best place for example implementations is something like Literate Programs which has a wiki specifically designed to hold documented source code in a wide variety of languages. Please note there are potential licensing issues involved as Wikipedia is GFDL while LP is not (though still an open license). Leland McInnes 06:35, 6 April 2006 (UTC)
thread_title:  Source Code 

message: Bucket sort is worst case O(n lg m) where m is the number of distinct possible elements. If m > number of buckets, then (as the article says) it must be recursively applied to the buckets. The recursion depth is O(lg m). COnsider sorting 16 bit ints. You can bucket sort with 256 buckets, applied twice. 24 bit ints will require 3 applications, 32 bit, 4 and so on.
Esentially, the number of passes (recursion depth) is linear in the key length, or logarithmic in the number of distinct keys.
Serviscope Minor 01:56, 21 November 2006 (UTC)
thread_title:  Wrong algorithmic order? 

message: My understanding is that Bucket or Bin sort is a class of sorting algorithms that is identified by the use of buckets or bins in the initial pass over the elements to be sorted. If your elements are evenly distributed and you know enough about the keys you can reduce the asymptotic running time by selecting an appropriate number of bins. This is how O(n log n) can be reduced to O(n). Beware! If you do not have an even distribution a large number of elements in a single bin will erase any benefits and you will have the added cost of the first run as well as any space and copy costs you accrued in your implementation. —The preceding unsigned comment was added by 24.198.83.109 (talk) 02:19, 26 April 2007 (UTC)
thread_title:  More Abstractly 

message: The articles bucket sort, pigeonhole sort, Counting sort, Tally sort and to some extent, radix sort constitute a mess due to the similarity (if not sameness in terms of the masic smart trick) of the algorithms. I learned Knuth & stuff like 30 years ago, so I am not of fresh memory, but IMO "bucket" and "pigeonhole" are synonyms. I cleased some carelless texts in a couple of places, but Expert attention is needed. `'Miikka 01:59, 4 July 2007 (UTC)
thread_title:  Mess 

message: The article should mention the amount of memory the sort requires.  (Some of the other sort articles do.)  —Preceding unsigned comment added by 206.53.197.12 (talk) 01:02, 27 October 2007 (UTC)
thread_title:  Memory Requirements 

message: I got this when ran implementation in C++:
Program received signal SIGSEGV, Segmentation fault.
:Yeah, that is a common effect of using C and C++, I know, I know. I've had such in Java too. ... said: Rursus (mbork³) 16:17, 17 November 2009 (UTC)
thread_title:  Implementation link 

message: I don't understand this fully:
 list sort(list s, typekey min, typekey max)
 {
        int i;
        typekey div, maxb[M], minb[M];
        list head[M], t;
        struct rec aux;
 
        if (s == NULL)
                return(s); 
        if (max == min)
                return s;
 
        div = ceil( (max - min) / M ); /* Find dividing factor */ 
 
        for (i = 0; i < M; ++i)
                head[i] = NULL; /* Place records in buckets */
 
        while (s != NULL) {
                i = (s->k - min) / div;
                if (i < 0)
                        i = 0;
                else if (i >= M)
                        i = M - 1;
                t = s;
                s = s->next;
                t->next = head[i];
                if (head[i] == NULL)
                        minb[i] = maxb[i] = t->k;
                head[i] = t;
                if (t->k > maxb[i])
                        maxb[i] = t->k;
                if (t->k < minb[i])
                        minb[i] = t->k;
        } /* sort iteratively */
 
        t = &aux;
        for (i = 0; i < M; ++i)
                if (head[i] != NULL) {
                        t->next = sort(head[i], minb[i], maxb[i]);
                        for( ; t -> next != NULL; t = t->next )
                                ;
                }
        return aux.next;
 }
What are:
list, aux, typekey? I can see that aux is a structure, bur what are its basic elements?
and I don't think this will run in TC as is (or with minor modifications)
--Sylvestersteele (talk) 17:28, 29 April 2008 (UTC)
thread_title:  implementation doubts 

message: The info-box currently says that the worst-case complexity is O(n^2), but the article doesn't discuss this at all.  So where does this come from?  Oli Filth(talk|contribs) 23:19, 31 August 2011 (UTC)
thread_title:  Worst-case complexity? 

message: There's no information in the article on if it's stable, I did Control-F for "stable" and found that this article is classified under "Stable sorts", but relevant information should be in the article. Also, I was looking online, and apparently it's stableness relies on the stableness of the sort that is used to sort the bins.  — Preceding unsigned comment added by 70.131.44.130 (talk) 03:55, 13 February 2019 (UTC)
thread_title:  Stable? 

message: The pseudocode given in the article will always result in an out-of-bounds error for zero-indexed arrays, as the expression floor(k × array[i] / M) will evaluate to k for the maximum element (where array[i] = M). This could be amended if M was set to max(array) + 1, though this feels kind of hacky. Any better suggestions?
Also note: A lot of publications assume the values of the elements in the array to lie in the half-closed interval [0,1). In that case, placing element array[i] into buckets[floor(k × array[i])] works. OwlSurojit (talk) 11:39, 6 October 2022 (UTC)
thread_title:  Out-of-bounds in pseudocode 

message: The pseudocode does not accept sorting negative numbers. 
If array[i] < 0 then the expression floor(k × array[i] / M) is evaluate to a negative index. 109.99.125.198 (talk) 11:38, 18 February 2023 (UTC)
thread_title:  sorting negative numbers