Bucket sequencing should be the simplest sort method and because of the simplicity there are many limitations and drawbacks
The downside is that it's a waste of space. If you need to sort the numbers very large then apply for a large space
Here's one of the simplest examples to introduce bucket sequencing
If a teacher wants to score 5 students with a score of 0-10 points
The bucket sort method is to create an array of size 11, a[0]-a[10] is initialized to 0.
When there is a score of 1 then a[1] = 1; If there are two scores of 1, that a[1] = 2.
So according to this idea, we can simply write a program to verify
#include <stdio.h>
int main (void)
{
int a[11],i,j,t;
for (i = 0; I <=; i++)
{
A[i] = 0;
}
for (i = 1; I <= 5; i++)
{
scanf ("%d", &t);
a[t]++;
}
for (i = 0; I <=; i++)
for (j = 1; J <= A[i]; j + +)
{
printf ("%d", I);
}
return 0;
}
If the input is 5 1 3 8 2
Then the output is 12358.