Consider the following quicksort program and modify it so


Programming Assignment-

Instructions:

Consider the following quicksort program and modify it so that it sorts the array in ascending order, uses pointers instead of indexes, and works with vectors.

Test the program on several data input arrays.

//Quick Sort Functions for Descending Order
//From https://mathbits.com/MathBits/CompSci/Arrays/Quick.htm void QuickSort(int * 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(int * 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
}

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Consider the following quicksort program and modify it so
Reference No:- TGS01552092

Now Priced at $30 (50% Discount)

Recommended (90%)

Rated (4.3/5)