Devise alternative strategies for choosing the pivot value in a quicksort. For example, pick the middle item. Reimplement the algorithm and then execute it on random data sets. Under what criteria does your new strategy perform better or worse than the strategy from this chapter?
Use the binary search functions given in the text (recursive and iterative). Generate a random, ordered list of integers and do a benchmark analysis for each one. What are your results? Can you explain them?
Implement the binary search using recursion without the slice operator. Recall that you will need to pass the list along with the starting and ending index values for the sublist. Generate a random, ordered list of integers and do a benchmark analysis.
Using a random number generator, create a list of 500 integers. Perform a benchmark analysis using some of the sorting algorithms from this chapter. What is the difference in execution speed?
A bubble sort can be modified to βbubbleβ in both directions. The first pass moves βupβ the list, and the second pass moves βdown.β This alternating pattern continues until no more passes are necessary. Implement this variation and describe under what circumstances it might be appropriate.
One way to improve the quicksort is to use an insertion sort on lists that have a short length (call it the βpartition limitβ). Why does this make sense? Reimplement the quicksort and use it to sort a random list of integers. Perform an analysis using different list sizes for the partition limit.