Documente Academic
Documente Profesional
Documente Cultură
Brian Curless
Spring 2008
Dependence on B
What if
B is a constant?
B is proportional to n?
count array
1
2
3
4
5
BucketSort
on 1s
Idea:
BucketSort on each digit, least significant to most
significant (lsd to msd)
Set number of buckets: B = radix.
Dont just count; insert the numbers into the buckets.
BucketSort
on 100s
Input data
478
537
9
721
3
38
123
67
1
721
3
3
123
537
67
478
38
9
9
Output:
Bucket sort
by 10s
digit
721
3
123
537
67
478
38
9
721
3
123
537
67
478
38
9
0
03
09
721
123
537
38
67
478
3
9
721
123
537
38
67
478
Your Turn
003
009
038
067
123
478
537
721
Another Example
3
9
38
67
123
478
537
721
BucketSort
on 1s
BucketSort
on 10s
BucketSort
on 100s
Output:
10
Radixsort: Complexity
b + log2b log2N
Example:
N = 1 million (i.e., ~220 ) 64 bit numbers, M = 264
log2N 20 b = 16
Total time?
Summary of sorting