Ich habe versucht, eine Quicksort-Implementierung zu schreiben, nachdem ich dieses Video auf youtube angeschaut habe. https://www.youtube.com/watch?v=MZaf_9IZCrc&t=215s aber es funktioniert nicht. Kann mir jemand sagen, was ich falsch mache? Danke FerdaQuick Sort-Implementierungsversuch
public class Trial{
public static void main(String []args){
int arr[] = {7, 3, 4, 2, 6, 1, 5};
quickSort(arr, 0, 6);
}
public static void quickSort(int[] arrInput, int start, int end){
int arr[] = new int[end-start+1];
for(int i=start, j=0; i<end; i++, j++){
arr[j]=arrInput[i];
}
int size = arr.length;
int pivotValue = arr[size-1];
for (int i=-1; i<arr.length; i++){
for(int j=0; j<arr.length; j++){
if(arr[j]< pivotValue){
int temp = arr[j];
i++;
arr[j] = arr[i];
arr[i] = temp;
}
for(int p = i; p< size-2; p++){
arr[p+1] = arr[p];
}
arr[i] = pivotValue;
quickSort(arr, 0, i);
quickSort(arr, i+1, size-1);
}
}
}
}
der quicksort Algorithmus, der von drei Teil zusammengesetzt ist, ein Teil namens Partition und thow anderer Teil sind sie zwei rekursiven Aufruf zu zwei Teil des partitionierten Array – thepaulo
das Video sehen Sie speack über die Partition des Arrays – thepaulo