Hello all,
I get the following error:
quicksort(int[],int,int)cannot be applied to(int[])
When I compile this:
import java.util.*;
public class Sort {
public static void main(String[] args){
Random rand = new Random();
int[] tab = new int[10];
for(int i = 0; i < tab.length; i++) {
tab[i] = rand.nextInt(100);
System.out.println("Before: ");
show(tab);
quicksort (tab);
System.out.println("After: ");
show(tab);
}
}
static void quicksort(int tab[], int x, int y) {
int i,j,v,temp;
i=x;
j=y;
v=tab[(x+y) / 2];
do {
while (tab[i]<v)
i++;
while (v<tab[j])
j--;
if (i<=j) {
temp=tab[i];
tab[i]=tab[j];
tab[j]=temp;
i++;
j--;
}
}
while (i<=j);
if (x<j)
quicksort(tab,x,j);
if (i<y)
quicksort(tab,i,y);
}
static void show (int tab[]) {
for (int i = 0; i <tab.length; i++) {
System.out.println(tab[i]);
}
}
}
What am I doing wrong?