package Sorts;
import static Sorts.SortUtils.*;
/**
* @author Varun Upadhyay (https://github.com/varunu28)
* @author Podshivalov Nikita (https://github.com/nikitap492)
* @see SortAlgorithm
*/
class QuickSort implements SortAlgorithm {
/**
* This method implements the Generic Quick Sort
*
* @param array The array to be sorted
* Sorts the array in increasing order
**/
@Override
public > T[] sort(T[] array) {
doSort(array, 0, array.length - 1);
return array;
}
/**
* The sorting process
*
* @param left The first index of an array
* @param right The last index of an array
* @param array The array to be sorted
**/
private static > void doSort(T[] array, int left, int right) {
if (left > int partition(T[] array, int left, int right) {
int mid = (left + right) / 2;
T pivot = array[mid];
while (left 0 1 1 2 2 3 4 5 5 5 7 8 9 12 32 44 111
print(array);
String[] stringArray = {"c", "a", "e", "b", "d"};
quickSort.sort(stringArray);
//Output => a b c d e
print(stringArray);
}
}