we must know the maximum value in the unsorted array
How many objects in the unsorted array
If maximum value is not big, and objects is a lot. such as all student
score (<100) in a school(1000). At this time, we can use Bucket sort.
Firstly, we must know how to handle duplicates. Secondly, Thirdly, we
must have enough memory. If you sort telephone which will not allow
duplicated value, you can build an bit array. And set bit 1 if there are
number exist. It will save a lot of memories. For duplicate, you can
store a link in each bucket. (array item)
Radix sort is cousin of Bucksort BucketSort is more efficient for ’Dense’
arrays, while RadixSort can handle sparse (well, not exactly sparse, but
spaced-out) arrays well. Use % operator to get radix each digit.
1 ~ nc- 1. 1 ~ 103- 1 You can use 10 as radix, and sort it 3 times.