Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Radix Sort

Status
Not open for further replies.

mj616

MIS
Joined
Jun 23, 2003
Messages
73
Location
US
I was wondering if anyone knew how to do a radix sort in Java. I need to write a program that asks a person to enter a number(n). Then I need to fill an array with n random numbers. After I fill the array I need to start the radix sort using two multidimensional arrays (Binone and Bintwo). After this is completed I need to fill the original array with the searched array. Here is my code I have so far if anyone can help it would be greatly appreciated.

import javax.swing.*;
import java.util.Random;

public class Binsort{
public static void main (String args[]){
String input= JOptionPane.showInputDialog
("How many Numbers do you wish to sort?");
int numbers= Integer.parseInt(input);


int[]numarray = new int[numbers];
for (int i=0; i<numbers; i++){

Random rn = new Random();
int random_num= rn.nextInt(i + 1);

numarray= random_num;
System.out.println (numarray);

}
int [][]binone= new int[10][numarray.length];
int [][]bintwo=new int [10][numarray.length];
for(int counter=0;counter<numarray.length;counter++){ int place = numarray[counter%1];
binone[place][counter]=numarray[counter];
System.out.println (&quot;Binone &quot; + place +&quot; &quot; + counter+ &quot; has value of &quot;+ binone [place][counter]);

}

System.exit(0);
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top