6. (20 points) Consider the following strategy for choosing a pivot element for the Partition subroutine of QuickSort, applie

6. (20 points) Consider the following strategy for choosing a pivot element for the Partition subroutine of QuickSort, applied to an array A Let n be the number of elements of the array A. . If n 24, perform an Insertion Sort of A and return Otherwise Choose 2n(1/2)elements at random from n; let S be the new list with the chosen elements Sort the list S using Insertion Sort and use the median m of S as a element Partition using pivot pivot m as a on the two parts – Carry out QuickSort recursively (a) How much time does it take to sort S and find its median? Give a e bound (b) If the element say about the sizes of the two partitions of the array A? obtained as the median of S is used as the pivot, what can m C we (c) Write a recurrence relation for the worst case pivoting strategy running time of QuickSort with this



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *