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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started