Void QuickSort (SeqList R, int low, int high)
{
// Fast sorting of R [low... high]
Int pivotPos; // the location of the benchmark record after Division
If (low {
// Sorting is required only when the Interval Length is greater than 1
Extends TPOs = Partition (R, low, high); // divide R [low... high]
QuickSort (R, low, pivotPos-1); // recursively sorts the left Interval
QuickSort (R, pivotPos + 1, high); // recursively sorts the right range
}
} // QuickSort
Void QuickSort (int [] x, int s, int t)
{
Int temp;
Int I = s, j = t;
If (s <t)
{
Temp = x [s];
Do
{
While (j> I & x [j]> = temp)
{
J --;
}
If (I <j)
{
X [I] = x [j];
I ++;
}
While (I <j & x [I] <= temp)
{
I ++;
}
If (I <j)
{
X [j] = x [I];
J --;
}
} While (I <j );
X [I] = temp;
QuickSort (x, s, J-1 );
QuickSort (x, j + 1, t );
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.