hello !!
i try to program radix sort , but i have NullPointerException when i run this code
public class ThreeRadixSort {
public Queue getSortedData(Queue queue){
Queue array[] = new Queue[10];
for(int i=1;i<=3;i++){
while(queue.front != null){
Student student = queue.dequeue();
if( i == 1)
array[(int)(student.id%10)].enqueue(student);
else if( i == 2)
array[(int)((student.id%100)/10)].enqueue(student);
else
array[(int)(student.id/100)].enqueue(student);
}
for(int j=0;j<=9;j++){
while( array[j] != null && array[j].front != null)
queue.enqueue(array[j].dequeue());
}
}
return queue;
}
}
The Exception show when the implement reach to
array[(int)(student.id%10)].enqueue(student);