Bucket sort
A bucket sort algorithmA sequence of logical instructions for carrying out a task. In computing, algorithms are needed to design computer programs. separates a list of dataUnits of information. In computing there can be different data types, including integers, characters and Boolean. Data is often acted on by instructions. into different collections of data, called 鈥榖uckets鈥. Empty buckets are set up at the start of the sort and are filled with the relevant data. Each bucket is then sorted, and the data is finally gathered back into a list.
Example
Imagine that you have a list of people who you want to sort by age, from youngest to oldest. A bucket sort can do this.
The list of ages is:
41, 15, 17, 32, 18, 28, 77 and 54
1. Set up a series of empty buckets.
2. Put the data into the correct buckets.
3. Buckets that have more than one item of data in them will be sorted (eg using bubble sort).
4. The data will then be gathered from each bucket and put back into a list.
The final list will be 15, 17, 18, 28, 32, 41, 54, 77.