Question: The quick sort is one of the better sorting algorithms available. However, the quick sort can have a worst case of O(n2) which is worse

The quick sort is one of the better sorting algorithms available. However, the quick sort can have a worst case of O(n2) which is worse if you compare it to something like the merge sort with O(nlog(n)) in all cases. One of the key reasons quick sort can exhibit such worst case is the bad selection of the pivot. In this assignment, you are required to come up with a quick sort that will try to avoid a bad scenario. Write a C++ code the does the following: Implement a quick sort algorithm that will accept an integer array of size n and in random order. Develop or research three different approaches as how you can pick the pivot. Write the code so the quick sort can choose among the above three different ways of picking the pivot. Run the algorithm for different sets of random data and make sure that for each set of data, you run the algorithm with all three options for the pivot selection. Record the number of key operations for each case. Report the numbers in a way that will allow you to draw a conclusion about which pivot selection approach was more efficient and how much variations you see between the different runs.

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!