What sort will we use to sort on digits?
Counting sort is obvious choice:
- Sort n numbers on digits that range from 1..k
- Time: O(n + k)
Each pass over n numbers with d digits takes time O(n+k), so total time O(dn+dk)
- When d is constant and k=O(n), takes O(n) time
How many bits in a computer word?