//Quick Sort Functions for
Descending Order
// (2 Functions)
void QuickSort(apvector &num, int top, int bottom)
{ // top = subscript of
beginning of array
// bottom = subscript of end of array
int middle;
if (top < bottom)
{
middle = partition(num, top, bottom);
quicksort(num, top, middle); // sort first section
quicksort(num, middle+1, bottom); // sort second section
}
return;
} //Function to
determine the partitions
// partitions the array and returns the middle subscript
int partition(apvector &array, int top, int bottom)
{
int x = array[top];
int i = top - 1;
int j = bottom + 1;
int temp;
do
{
do
{
j - -;
}while (x >array[j]);
do
{
i++;
} while (x
if (i < j)
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}while (i < j);
return j; // returns
middle subscript }
+ نوشته شده در چهارشنبه بیست و سوم دی ۱۳۸۸ ساعت 16:55 توسط پروژه برنامه نویسی و طراحی وب سایت
|
رشته من نرم افزار است. در حال حاضر بر روي پروژه هاي برنامه نویسی ، طراحی وب سایت ، تحلیل پروژه های نرم افزاری و طراحی پایگاه داده فعالیت می کنم.