1. End condition: Low = high
2. Fast sorting needs to be separated and governed. Therefore, the location to be split is the location where the current element is arranged.
3. For a single arrangement, an element is placed in the correct position. Her left side is smaller than her, and her right side is larger than her.
package com.jue.quicksort;public class Quicksort {/** * @param args */public static void main(String[] args) {// TODO Auto-generated method stubint data[] = { 8, 3, 7, 1, 5, 6, 4, 9, 2 };logs("old : ", data);quickSort(data, 0, data.length - 1);logs("new : ", data);}static void logs(String str, int[] data) {StringBuffer sb = new StringBuffer(str);for (int value : data) {sb.append(value + " ");}System.out.println(sb);}public static void quickSort(int[] data, int low, int high) {if (low >= high) {return;}int index = getSortedIndex(data, low, high);quickSort(data, low, index - 1);quickSort(data, index + 1, high);}private static int getSortedIndex(int[] data, int low, int high) {int currentData = data[low];int currentDataIndex = low;while (low < high) {if (currentDataIndex == low) {if (currentData > data[high]) {data[low] = data[high];data[high] = currentData;currentDataIndex = high;low++;} else if (currentData <= data[high]) {high--;}} else if (currentDataIndex == high) {// move to leftif (currentData < data[low]) {//data[high] = data[low];data[low] = currentData;currentDataIndex = low;high--;} else if (currentData >= data[low]) {low++;}}}return currentDataIndex;}}