[Solved] COEN12-Project 6 Quick Sorting

$25

File Name: COEN12-Project_6_Quick_Sorting.zip
File Size: 282.6 KB

SKU: [Solved] COEN12-Project 6 Quick Sorting Category: Tag:
5/5 - (1 vote)

You only have to implement a sorting algorithm that youve already learned in class, and youll 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.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] COEN12-Project 6 Quick Sorting
$25