NamespaceSolodatastructure { ClassMyquicksort { /**////<Summary> ///Quick Sorting Algorithm ///</Summary> ///The fast sorting method is unstable, and the time complexity O (nlog2n) is the fastest sorting method of the same order of magnitude. ///<Param name = "arr">Partitioned Array</Param> ///<Param name = "low">Low-end array tagging</Param> ///<Param name = "high">Array High-end subscript</Param> ///<Returns> </returns> StaticIntPartition (Int[] Arr,IntLow,IntHigh) { //Perform a quick sorting and return the location of the central axis record //Arr [0] = arr [low]; IntBytes=Arr [low];//Place the central axis in arr [0] While(Low<High) { While(Low<High&&Arr [High]> =Token) --High; //Move a record smaller than the central axis to the lower end Swap (RefArr [High],RefArr [low]); While(Low<High&&Arr [low]<=Token) ++Low;
Swap (RefArr [High],RefArr [low]); //Move larger than the central axis record to high-end }
Arr [low]=Break;//Move the center axis to the correct position ReturnLow;//Returns the center axis position. } StaticVoidSwap (RefIntI,RefIntJ) { IntT;
T=I;
I=J;
J=T;
} StaticVoidQuicksort (Int[] Arr,IntLow,IntHigh) { If(Low<High-1)//When arr [low, high] is null or only one record does not need to be sorted {< br> int trim = partition (ARR, low, high);
quicksort (ARR, low, margin - 1 );
quicksort (ARR, margin + 1 , high);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service