Home / Expert Answers / Computer Science / nbsp-a-implement-quicksort-as-explained-in-class-with-varying-pivot-calculation-methods-and-pa374

# (Solved):   (a) Implement QuickSort, as explained in class, with varying pivot calculation methods and ...

(a) Implement QuickSort, as explained in class, with varying pivot calculation methods and varying cutoffs. You may assume that all your input lists contain only integers, are duplicate-free, and are of length at most 100. pivot calculation methods: pivot = first list element, pivot = second list element, pivot $$=$$ element at middle position of list, pivot = median-of-three (as explained in class) cutoffs: no cutoff, cutoff $$c=5$$, cutoff $$c=10$$, cutoff $$c=20$$ (a cutoff here means an array size such that every array of size less than or equal to $$c$$ will be sorted with Insertion Sort). Add a counter to your implementation. Every time a comparison of two list elements is made, the counter is increased by one (also in the Insertion Sort routine). (b) Test your implementation (all $$4 \times 4=16$$ variants) on three different lists of length 100 and, each time, report the total number of comparisons recorded in your counter. One of the input lists should be sorted in increasing order, one sorted in decreasing order, and one random. Show the 48 resulting values organized in a table, for better readability.

We have an Answer from Expert