Question: Q: Modify your QuickSort code to experiment with different choice of pivots. Try at least 2 methods: random element and median of first, middle, and
Q: Modify your QuickSort code to experiment with different choice of pivots. Try at least 2 methods: random element and median of first, middle, and last elements. See Cormen et al. section 7.3 for an easy way to implement the random element version. Before you implement this, write down your hypothesis as to what the effect will be. Its OK to be wrong here. For instance, if your code takes 10 seconds to sort 1 million numbers using the last-element pivot, do you think the random element or median element will speed up or slow down your code? By how much? A couple of seconds, or negligible? After you run your code, explain why you were right or wrong. Include this discussion as a long comment in your code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
