What part has you stumped?
I have just hacked together a quick bucket sort method in Ruby and the process would appear to have three stages...
1. Setup your buckets.
2. Iterate over your data set and stick each value in the corresponding bucket.
3. Look in each bucket and see if you have anything in it.
My crufty code... Code: class Array
def bucketsort
buckets = Array.new((self.max + 1), 0)
self.each { |i| buckets[i] += 1 }
sorted = Array.new
buckets.each_index { |index| buckets[index].times { sorted << index } }
return sorted
end
end If I get time later I will try and rewrite it in C++, but I wouldn't hold your breath
Regards
ed
__________________
I dreamt that a large eagle circled the room three times and then got into bed with me and took all the blankets.
Last edited by SpookyEddy : April 19th, 2005 at 03:22 PM.
|