1. Basic Ideas
By sorting the data that will be sorted into two separate parts, a part of all the data is smaller than the other part of all the data, and then the two parts of the data for the rapid sorting, the entire sequencing process can be recursive, so as to achieve the entire data into an ordered sequence.
2, the algorithm steps to get sorted array Select the appropriate number as the Sort datum number (in general, select the first number of arrays or sub arrays). Place the array to be sorted smaller than the datum to the left of the datum number sub1, and the sub2 to the right of the datum number, larger than the base number. If Sub1 or sub2 have only one element, then return directly, otherwise recursively rearrange the sub1 or sub2.
3. Java Code Implementation
public class QuickSort {/** * @Comment fast Sort One * @Author Ron * @Date October 25, 2017 afternoon 12:12:32 * @ret
Urn */static void Quiksort (int[] sources,int leftindex,int rightindex) {if (Leftindex >= rightindex) {
If the left subscript is greater than or equal to the lower right subscript, the number of sub array elements obtained after sorting is less than or equal to 1, sorted completes, return directly;
int startIndex = boundary (Sources,leftindex,rightindex);
Quiksort (sources,leftindex,startindex-1);
Quiksort (Sources,startindex+1,rightindex); /** * @Comment binary to sort array * @Author Ron * @Date October 25, 2017 afternoon 12:12:24 * @return * * * Stati
c int boundary (int[] Sources,int leftindex,int rightindex) {int startindex=leftindex;
int endindex = Rightindex;
int basenum = Sources[leftindex]; while (StartIndex < Endindex) {while (StartIndex < Endindex && Sources[endindex] >= basenum)
{endindex--; } Sources[startiNdex]=sources[endindex];
while (StartIndex < Endindex && Sources[startindex] <= basenum) {startindex++;
} Sources[endindex]=sources[startindex];
} Sources[startindex]=basenum;
return startIndex;
public static void Main (string[] args) {int[] sources={3,9,4,1,7,6,2,0,8};
Quiksort (sources,0,sources.length-1);
String result= "";
for (int i = 0; i < sources.length. i++) {result = sources[i]+ "";
} System.out.println (Result); }
}