Showing posts with label Radix Sort. Show all posts
Showing posts with label Radix Sort. Show all posts

Friday, April 15, 2011

Radix Sort


import java.util.*;
class radixsort
{
                static void sort(int a[],int n)
    {
                   int large, num,l,d=1;
                   int bucket[][]=new int[10][10];
                   int b[]=new int[10];
                   large=a[0];
                   for(int i=1;i<n;i++)
                   {
                                  if(large<a[i])
                                  large=a[i];                        
                }
                   num=0;
       while(large>0)
                {
                                num++;
                                large=large/10;
                    }
                for(int p=0;p<num;p++)
        {
                                   for(int k=0;k<10;k++)
                                    b[k]=0;
                               
                                   for(int i=0;i<n;i++)
                                   {