Question: For this lab, you will first populate an array with integer values provided by a user and then you wau sur L the array. You

 For this lab, you will first populate an array with integervalues provided by a user and then you wau sur L the

For this lab, you will first populate an array with integer values provided by a user and then you wau sur L the array. You will implement ve quicksort algorithm. Quicksort Algorithm Quicksort, also known as the partition-exchange sort, is an efficient algorithm From Wikipedia: Quicksort first divides a large array into two smaller subarrays the low elements and the high elements. Quicksort can then recursively sort the sub-arrays l, Pick an element, called a pivot, from the array. 2. Reorder the array so that all elements with values less than the pivor come before the pivot, while all elements with values greater than the pivot come after it (equal values cango either way). After this partitioning. the pivor is in its final position. This is called the partition operation. 3. Recursively apply the above steps to the sub-array of elements with smaller values and separately to the sub-array of elements with greater values. The base case of the recursion is arrays of size zero or one. which never need to be sorted. Implementation At the top of your program, define a constant to restrict the maximum size of your array: #define MAXLARRAYLSIZE 50 You will implement 5 functions as well as your main function. The function prototypes are: int populate array int array[] Fill array with values from user. void print array int array int n Print out the array values void swap( int array int index1, int index Swap two array elements. void quicksort( int array int low, int high Sorting algorithm int partition nt low, int hieh ind the partition point (pivot array These function prototypes will appear near the beginning of the program. Later in the program, you will provide the function implementation (you repeat the function prototype but this time you provide the function body as well). main Function 1. in your main function, declare an array of size MAx ARRAY SIZE 2. Next. call your function populate array described below) and save the result as variable n. 3. Print out the value in the array by calling your function print array (described below). 4. Now call your sorting algorithm with the line: quicksort ay, a, n-1)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!