Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Random;
- import java.util.Arrays;
- import static java.lang.System.*;
- public class Quicksort {
- private int[] thearray;
- public Quicksort() {
- }
- public Quicksort(int[] apadarray) {
- this();
- thearray = apadarray;
- }
- public int[] Randomize(int[] thearray) {
- Random rand = new Random();
- for(int i = 0; i<thearray.length; i++){
- thearray[i] = rand.nextInt(11);
- }
- return thearray;
- }
- public int[] Sort(int[] thearray){
- thearray = Randomize(thearray);
- out.println(Arrays.toString(thearray));
- for(int j = 0; j<thearray.length-1; j++){
- int minIndex = j;
- for(int k = j+1; k<thearray.length; k++){
- if(thearray[k]<thearray[minIndex]) minIndex = k;
- }
- int temp = thearray[j];
- thearray[j] = thearray[minIndex];
- thearray[minIndex] = temp;
- }
- return thearray;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement