[SOLVED] COEN12-Project 6 Quick Sorting

25.99 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon project6-wnwk7c.zip (119.5 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

You only have to implement a sorting algorithm that you’ve already learned in class, and you’ll be modifying his implementation of a set ADT.

1        Interface

Only one interface function must be modified for this assignment:

  • void *getElements(SET *sp); allocate and return a sorted array of elements in the set pointed to by sp

2        Implementation

As required by Professor Loony, you will modify the getElements function to return a sorted array of elements in the set. He requires you to use the quicksort algorithm, which was discussed in class and in the text. Quicksort is a recursive sorting algorithm that is very fast in practice. The basic algorithm works as follows:

  1. Choose a value from the subarray to be sorted. This value is called the pivot. The choice of pivot does notaffect the correctness of the algorithm, but can affect its efficiency.
  2. Partition the subarray around the pivot so that the pivot is in the correct location, all values to the left of thepivot are less than the pivot, and all values to the right of the pivot are at least the value of the pivot.
  3. Recursively sort the subarrays to the left and right of the pivot.
  • project6-wnwk7c.zip