

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Due Date: see class website
Implement radixsort in Java.
1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16
Note that the size of the counting array will be k = 2bits. Observe the run-time for each value of bits. Make a table for the run-time versus d, where d is the number of passes radixsort makes. Remember that the number of passes made by radixsort is d = dMACHINE WORD SIZE/bitse. For most machines the constant MACHINE WORD SIZE is 32, but your program should not rely on this assumption. For example, in Java, we can get the word size from the constant Integer.SIZE.
and make a table of input size versus run-time.
Notes:
public void generate_random_array(int A[], int n, long seed) { Random generator = new Random(seed); for (int i=0; i<n; i++) A[i] = generator.nextInt(Integer.MAX_VALUE); }
// returns true if A[0..n-1] is sorted. // return false if A[0..n-1] is not sorted. boolean CheckIfSorted(int A[])
long totalTime = System.currentTimeMillis(); radixsort(...); totalTime = System.currentTimeMillis() - totalTime;
However, you will need to use the method report cpu time from the NativeTiming class for the final version that you submit.
/*
private int getbits(int x, int start, int n) { return ((x >>> start) & ((1<<n) - 1)); }