Mein Quicksort Problem: he method quickSort(int[], int, int)

Status
Nicht offen für weitere Antworten.

scaary

Bekanntes Mitglied
Servus.
Ich hab versucht, mir selbst ein kleines Quicksortdings zu machen, was aber mit folgendem Fehler abgewehr wird:

java.lang.Error: Unresolved compilation problem:
The method quickSort(int[], int, int) is undefined for the type Test

at Test.main(Test.java:14)
Exception in thread "main"


für folgenden Code

Code:
public class Quicksort {
	
	


	
	static void quickSort(int[] array, int start, int end){
		// Aus einem mir unerfindlichen Grund verweigert eclipse die annahme der comparable Angabe.
		printer(array);

		if(start > array.length || start < 0 || start <= end || array.length == 0 || array.length == 1){
			return;
		}
		
		if(end > array.length - 1 || end == 0){
			end = array.length - 1 ;
			System.out.println("Iregular end-value. End-value replaced.");
		}
		
		if(end == 0){
			end = array.length - 1;
			System.out.println("Iregular end-value. End-value replaced.");
		}
		
		
		if(array.length == 2){
			if(array[0] > array[1]){
				int tmp = array[0];
				array[0] = array[1];
				array[1] = tmp;
			}
			return;
		}

		int pivot = start;
		int runnerFront = pivot + 1;
		int runnerBack = end;

		printer(array);

		while(runnerFront < runnerBack){

			while (array[runnerFront] < array[pivot] && runnerFront < array.length){
				runnerFront++;
			}

			while(array[runnerBack] > array[pivot] && runnerBack < array.length){
				runnerBack++;
			}

			if(runnerFront < runnerBack){
				int tmp = array[runnerFront];
				array[runnerBack] = array[runnerFront];
				array[runnerFront] = tmp;

			}
		}
		printer(array);

		int tmp = array[pivot];
		array[pivot] = array[runnerFront];
		array[runnerFront] = tmp;
		quickSort(array, start, runnerBack - 1);
		quickSort(array, runnerBack + 1, end);
		return;
		
		





	}	static void printer(int []array){
		for(int i = 0; i < array.length; i++){
			System.out.print(array[i]);
			System.out.print(", ");
			System.out.println();
		}
	}
}


Code:
import java.lang.Math;


public class Test {
	public static void main(String[] args){
		
		int[]array1 = new int[50];
		
		for(int i = 0; i < array1.length; i++){
			double number = Math.random() * 100; 
			array1[i] = (int)number;
		}
		
		quickSort(array1, 0, array1.length - 1);
		
	}

}

Kann mir jemand bitte sagen, worans scheitert?
Danke!!
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben