0

I have tried to write a code for Radix sort but i am getting Null Pointer Exception. Although i tried to dry run it, and getting required action.

    public class RadixSort 
    {
        public static void main(String arg[])
        {
            int a[] = {74, 68, 20, 231, 29, 44};

            StandardQueue Q[] = new StandardQueue[10];

            int div = 1;
            int t;
            int num = max(a);//Gets Largerst Number

            int c = 0;
            while(num > 0)
            {
                c++;
                num /= 10;
            }

            for(int p = 1; p <= c; p++)
            {
                for(int i = 0; i < a.length; i++)
                {
                    t = a[i] / div % 10;
                    **Q[t].enQueue(a[i]);** //This Gives Null Pointer
                }

            }
        }
    }
Xirexor
  • 19
  • 4

0 Answers0