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 th

 

(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

View Expert Answer

Expert Answer


When the list of items to be sorted contains a lot of duplicate values, we can improve QuickSort by grouping all the values that are equal to the pivo
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe