@@ -0,0 +1,2269 @@
+package de.sebhn.algorithm.exercise8;%0D%0A%0D%0Aimport java.util.Arrays;%0D%0A%0D%0Apublic class QuickSort %7B%0D%0A%0D%0A%0D%0A  public static void main(String%5B%5D args) %7B%0D%0A    String stringToSort = %22djiebgchaf%22;%0D%0A    char%5B%5D sorted = quickSort(stringToSort.toCharArray(), 0, stringToSort.length() - 1);%0D%0A    System.out.println(Arrays.toString(sorted));%0D%0A  %7D%0D%0A%0D%0A  private static char%5B%5D quickSort(char%5B%5D arrayToSort, int startIndex, int endIndex) %7B%0D%0A    int leftIndex = startIndex;%0D%0A    int rightIndex = endIndex;%0D%0A    int midIndex = (leftIndex + rightIndex) / 2;%0D%0A%0D%0A    preSortLeftMidRightWithBubbleSort(arrayToSort, leftIndex, rightIndex, midIndex);%0D%0A%0D%0A    int diffEndAndStart = endIndex - startIndex;%0D%0A    boolean isQuickSortNecesaryAfterBubbleSort = diffEndAndStart %3E 2;%0D%0A    if (isQuickSortNecesaryAfterBubbleSort) %7B // big problem%0D%0A      char w = arrayToSort%5BmidIndex%5D; // divide:%0D%0A%0D%0A      do %7B%0D%0A        while (arrayToSort%5BleftIndex%5D %3C w) %7B%0D%0A          leftIndex++; // search leftIndex%0D%0A        %7D%0D%0A        while (arrayToSort%5BrightIndex%5D %3E w) %7B%0D%0A          rightIndex--; // search rightIndex%0D%0A        %7D%0D%0A        if (leftIndex %3C= rightIndex) %7B%0D%0A          swap(arrayToSort, leftIndex, rightIndex); // swap%0D%0A          leftIndex++;%0D%0A          rightIndex--;%0D%0A        %7D%0D%0A      %7D while (leftIndex %3C= rightIndex); // until finished%0D%0A%0D%0A      if (startIndex %3C rightIndex) %7B%0D%0A        quickSort(arrayToSort, startIndex, rightIndex); // conquer left%0D%0A      %7D%0D%0A      if (leftIndex %3C endIndex) %7B%0D%0A        quickSort(arrayToSort, leftIndex, endIndex); // conquer right%0D%0A      %7D%0D%0A    %7D%0D%0A    return arrayToSort;%0D%0A  %7D%0D%0A%0D%0A  /**%0D%0A   * Small problem%0D%0A   */%0D%0A  private static void preSortLeftMidRightWithBubbleSort(char%5B%5D arrayToSort, int leftIndex,%0D%0A      int rightIndex, int mid) %7B%0D%0A    if (arrayToSort%5BleftIndex%5D %3E arrayToSort%5Bmid%5D) %7B%0D%0A      swap(arrayToSort, leftIndex, mid);%0D%0A    %7D%0D%0A    if (arrayToSort%5Bmid%5D %3E arrayToSort%5BrightIndex%5D) %7B%0D%0A      swap(arrayToSort, mid, rightIndex);%0D%0A    %7D%0D%0A    if (arrayToSort%5BleftIndex%5D %3E arrayToSort%5Bmid%5D) %7B%0D%0A      swap(arrayToSort, leftIndex, mid);%0D%0A    %7D%0D%0A  %7D%0D%0A%0D%0A  private static void swap(char%5B%5D a, int index1, int index2) %7B%0D%0A    char charAtIndex1 = a%5Bindex1%5D;%0D%0A    char charAtIndex2 = a%5Bindex2%5D;%0D%0A    // swap%0D%0A    a%5Bindex1%5D = charAtIndex2;%0D%0A    a%5Bindex2%5D = charAtIndex1;%0D%0A  %7D%0D%0A%7D%0D%0A

implement quicksort