Welcome. I have a radix sorting method that uses an array to go through, but has to have another array (bin) that will store in an empty queue. I am confused as to how I would make a queue for the bins. I also have a findPlace method that finds the place of the each digit when called upon. So, here is what I got. Can someone help me find what I am missing? Thanks so much for your time.
public static void radix(int [] list){
int [] bin = new int[10];
ArrayQueue<Integer> part = new ArrayQueue<Integer>(); // EDIT What would I do with this queue??
int num = 0;
for(int i=0;i<list.length;i++)
{
bin[i] = 0;
}
for(int pass=0;pass<list.length;pass++)
{
for(int num=0;num<list.length;num++)
{
int digit=findPlace(bin[pass], num);
}
bin[digit].add(list[num]); // add to the bin
}
// Put back into list
for(int h=0; h<10; h++)
{
while(!bin[h].isEmpty())
{
list[num] = bin[queueNum].remove();
num++;
}
}
}
public static int getPlace (int x, int place)
{return x/place % 10;}
I also made a method to find the bucket, So i just need to know how I would put it into an array, would I just do this? part.add(getPlace(x, place));?