Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Bucket sort
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Sorting algorithm}} {{Infobox algorithm |class=[[Sorting algorithm]] |data=[[Array data structure|Array]] |time=<math>O\left(n^2\right)</math> |average-time=<math>O\left(n+\frac{n^2}{k}+k\right)</math>, where k is the number of buckets. <math>O(n), \text {when } k \approx n</math>. |space=<math>O(n + k)</math> }} [[File:Bucket sort 1.svg|right|frame|Elements are distributed among bins]] [[File:Bucket sort 2.svg|right|frame|Then, elements are sorted within each bin]] '''Bucket sort''', or '''bin sort''', is a [[sorting algorithm]] that works by distributing the elements of an [[Array data structure|array]] into a number of buckets. Each bucket is then sorted individually, either using a different sorting algorithm, or by recursively applying the bucket sorting algorithm. It is a [[distribution sort]], a generalization of [[pigeonhole sort]] that allows multiple keys per bucket, and is a cousin of [[radix sort]] in the most-to-least significant digit flavor. Bucket sort can be implemented with comparisons and therefore can also be considered a [[comparison sort]] algorithm. The [[Analysis of algorithms|computational complexity]] depends on the algorithm used to sort each bucket, the number of buckets to use, and whether the input is uniformly distributed. Bucket sort works as follows: # Set up an array of initially empty "buckets". # '''Scatter''': Go over the original array, putting each object in its bucket. # Sort each non-empty bucket. # '''Gather''': Visit the buckets in order and put all elements back into the original array.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)