Hi,
mein Selectionsort funktioniert irgendwie nicht und ich finde das Problem nicht.
mein Selectionsort funktioniert irgendwie nicht und ich finde das Problem nicht.
Java:
public void selectionsort(int[] A, int l, int länge){
if (l<länge){
int maxZahl = max(A, l,l+1,länge);
//sortieren
int tmp = A[länge];
A[länge]=A[maxZahl];
A[maxZahl]=tmp;
//ende
selectionsort(A,l,länge-1); //Rechte Schranke um 1 vermindert.
}
}
public int max(int[] A, int maxZahl, int l, int länge){
if(l<=länge){
if(A[l] > A[maxZahl]){
return max(A,1,l+1,länge);
}else{
return max(A,maxZahl,l+1,länge);
}
}else{
return maxZahl;
}
}