Bead sort very alternative [goblin also very alternative], read you will know, first introduce ideas, and then decomposition process
This is its English paper http://www.cs.auckland.ac.nz/~jaru003/research/publications/journals/beadsort.pdf
The screen captured from the paper above
First understand a concept, otherwise it is not easy to understand, a number 3 with 3 to represent
A number 9 is represented by 9, the bead in the order of beads refers to each of the 1, it puts each 1 into a bead, these beads are strung together, imagine the abacus and candied fruit
Figure 1
1 of the three beads represent the number 3, two beads represent the number 2, this OK continues, here the 3 and 2 are called bead
Figure 2
In Figure 2 (a), there are two numbers, 4 and 3, strung on four lines respectively, so the last bead of the number 4 falls, because it is empty below, the freedom falls behind and becomes Figure 2 (b)
Figure 2 (c) randomly gave four numbers, respectively, 3,2,4,2, the beads are free to fall, it becomes (d), the end of order, 2,2,3,4
These are the essence of the Pearl sort.
Figure 3
The N in 3 indicates the length of the array to be sorted, how many numbers there are, and the horizontal representation of the layer
m indicates how many beads, that is, how many 1, depending on the maximum number is a few
such as arrays to be queued [6 2 4 1 5 9]
Let all the beads do free fall
9 Nothing good to fall, it's at the bottom
5, there is nothing to fall, all have a support point
1 also does not need to slide
4 except the first bead does not move, the other three all fall, fall to 1 position becomes below this
The details of the process are not drawn, the principle is that you have a fulcrum below, you do not have to slide, and finally become the bottom of this, sorted
Results are obtained from top to bottom sequential output: [1 2 4 5 6 9]
Beads Sort Bead Sort