Bucket 0 contains 4 8 10 14 90 bucket 1 contains 110

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ificant digit) for all numbers. Create 10 "buckets" (or lists) labeled 0,1,2,3,4,5,6,7,8,9. Put each number in L into the appropriate bucket, being careful to keep the numbers in the same relative order in each bucket as in the original list. Then, after processing the entire list in this way, rebuild the list, starting from bucket 0, then bucket 1, etc. until all the numbers from bucket 9 has been included. Now, repeat the process (recursively) for the tens' digits, using the list that you just built. The process continues for each of the remaining digits, always starting from the list just built. Example: Suppose you are sorting the list [10, 4, 14, 90, 110, 8]. • You start by sorting the ones' digits. So, bucket 0 contains (in order) 10, 90, 110; bucket 4 contains (in order) 4, 14; and bucket 8 contains 8. All other buckets are empty. Rebuilding the list, we get [10, 90, 110, 4, 14, 8]. • Now, sort the tens' digits. Bucket 0 contains...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online