Question
This is in java. You have to sort an array of student-ids. Student ids have a range 1- 99999. Write a program to sort the
This is in java. You have to sort an array of student-ids. Student ids have a range 1- 99999. Write a program to sort the following student id's in ascending order using radix (bucket) sort and print the sorted list on console. You are not allowed to use Java API list classes.
Format of I/O:
Enter the list of integers to be sorted, separated by blank spaces: 8178 32 315 19 45921 7130 4 563 1999 390 2873 431
Number of passes required: 5
Pass 1 buckets are: 0: 390 7130 1: 431 45921 2: 32 3: 563 2873 4: 4 5: 315 6: 7: 8: 8178 9: 19 1999
Pass 2 buckets are: 0: 4 1: 19 315 2: 45921 3: 32 431 7130 4: 5: 6: 563 7: 2873 8178 8: 9: 390 1999
Pass 3 buckets are: 0: 4 19 32 1: 7130 8178 2: 3: 315 390 4: 431 5: 563 6: 7: 8: 2873 9: 1999 45921
Pass 4 buckets are: 0: 4 19 32 315 390 431 563 1: 1999 2: 2873 3: 4: 5: 45921 6: 7: 7130 8: 8178 9:
Pass 5 buckets are: 0: 4 19 32 315 390 431 563 1999 2873 7130 8178 1: 2: 3: 4: 45921 5: 6: 7: 8: 9: Sorted List: 4 19 32 315 390 431 563 1999 2873 7130 8178 45921
Your program must the print out of the contents of each bucket after every pass and the final sorted list to get full credit.
b) Repeat the same sort with the same input using 100 buckets numbered 0..99 instead of 10 buckets. For the 100 buckets you should look at two digits at a time in every pass for every number starting from the least significant position. So 8178 would go to bucket #78 in pass 1 and bucket #81 in pass 2. You must the print out of the contents of each bucket after every pass to and the final sorted list, as shown in the example in part a) to get full credit.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started