Question: I'm supposed to make a Radix Sort using a queue and this is what I have: RadixSort Class: public class RadixSort { int[] array={304,319,819,1420,9201,1212,4102,8196,1076,1331,1471,2193,1055}; Queue[]

I'm supposed to make a Radix Sort using a queue and this is what I have:

RadixSort Class:

public class RadixSort { int[] array={304,319,819,1420,9201,1212,4102,8196,1076,1331,1471,2193,1055}; Queue[] digits=new Queue[13]; public RadixSort(){ System.out.println("Unsorted array:"); printArray(); for(int i=0;i

Queue Class:

public class Queue{ private int[] array; private int Max; private int front, rear, count=0;

public Queue(int size){ Max=size; front=rear=0; count=0; array=new int[size]; } public int getSize() { return count; }

public boolean isEmpty(){ return count==0; } public void enque(int a){ if(count+1<=Max){ array[rear]=a; rear++; count--; System.out.println(a + " Was added to the rear"); } else{ System.out.println("Queue Full"); } } public void deque(){ if(count>0){ System.out.println(array[front] + " Was removed from the front"); array[front]=-1; front++; count--; } else{ System.out.println("Queue empty"); } } public int getFront(){ return front; } public void display(){ System.out.println("Queue: "); for (int i=0;i

This is the output:

Unsorted array: 249 219 789 110 911 112 518 816 176 167 671 233 455 9 249 Was added to the rear 9 219 Was added to the rear 9 789 Was added to the rear 0 Queue Full 1 911 Was added to the rear 2 112 Was added to the rear 8 518 Was added to the rear 6 816 Was added to the rear 6 176 Was added to the rear 7 167 Was added to the rear 1

Can someone explain the problem?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!