I have successfully implemented Radix sort but I have the following code that I would like to convert to be created by a loop.
private static LinkedList[] bucket = {
new LinkedList(), // -9
new LinkedList(), // -8
new LinkedList(), // -7
new LinkedList(), // -6
new LinkedList(), // -5
new LinkedList(), // -4
new LinkedList(), // -3
new LinkedList(), // -2
new LinkedList(), // -1
new LinkedList(), // 0
new LinkedList(), // 1
new LinkedList(), // 2
new LinkedList(), // 3
new LinkedList(), // 4
new LinkedList(), // 5
new LinkedList(), // 6
new LinkedList(), // 7
new LinkedList(), // 8
new LinkedList() // 9
};
However I cannot figure out how I might go about doing this. I tried this but I get compiler errors.
private static LinkedList[] bucket;
int thing = 19;
while(thing != 0){
bucket = new LinkedList();
thing--;
}
This is not critical to the functionality of my radix sort as it works flawlessly, I just think it would be cleaner to initialize my buckets with a loop. That said if someone could enlighten me on how to do this I would be very grateful.
bucket = new LinkedList();bucket is an array not a LinkedList.