I'm going to output the object element, but it not successful to output the value to public. Anyone have some idea? I have tried to implement the following code.
import java.util.Scanner;
public class Qa {
private static void qb(int left, int right) {
int pivotIndex = left; //set first element as pivot
int storeIndex = pivotIndex + 1;
for (int i = pivotIndex + 1; i <= right; i++)
if (element[i] < element[pivotIndex]) {
swap(i, storeIndex);
storeIndex++;
}
swap(pivotIndex, storeIndex - 1);
printElement();
//recursion
if (storeIndex - 2 - left >= 1)
qsort(left, storeIndex - 2);
if (right - storeIndex >= 1)
qsort(storeIndex, right);
}
private static void swap(int n1, int n2) {
int tmp = element[n1];
element[n1] = element[n2];
element[n2] = tmp;
}
private static void printElement() {
for (int i = 0; i < element.length; i++)
System.out.print(element[i] + " ");
System.out.println("");
}
}