Bucket sort
Barrel sequencing has been used since the 1956, and the basic idea of the algorithm is proposed by E.J.ISSAC and R.c.singleton.
This algorithm is like having 11 barrels, numbered from 0~10. Each occurrence of a number, in the corresponding number of buckets put a
A little flag, and then just count the few small flags in each bucket OK. For example, there are 1 small flags in bucket 2nd, indicating
2 appeared once, and in the 3rd barrels there were 1 small flags, indicating that 3 appeared once, and 5th were in the barrels of 2 flags, indicating 5
Appeared two times, and in 8th barrels there were 1 small flags, indicating that 8 appeared once.
Code
1 defMain ():2Book =list ()3 for_inchRange (1001):4 book.append (0)5 6n = Int (input ('Number of buckets to sort by:'))7 8 for_inchrange (n):9t =int (input ())TenBOOK[T] + = 1 One A forIinchReversed (Range (1,1001)): - forJinchRange (Book[i]): - PrintI the - if __name__=='__main__': -Main ()
Python implements bucket ordering of data structures and algorithms