Question: We consider a modification of the Quick Sort algorithm presented in class. Normally we pick a pivot at random and use it as pivot. Say

We consider a modification of the Quick Sort algorithm presented in class. Normally we pick a pivot at random and use it as pivot. Say that we instead we insert a step to calculate the median-of-medians (say, using groups of 5) and use that as pivot instead. In other words, Modified Quick Sort is: 1. Group the n elements in the array in groups of 5. Compute the median for each group 2. Let m be the median-of-medians 3. Partition input array around the meclian-of-medians 4. Execute Modified Quick Sort on the two sub arrays indicated by the partition (a) After step 3, what are the possible positions that m can have? (b) Write the recursion for the run time of the algorithm, incorporating IRVs where needed. Explain briefly why your recursion is correct. (c) What is the run time of the algorithm? For this question and this question only) you need not fully solve the recurrence. Just justify your answer with a few sentences Make sure to specify if you mean worst case or expected worst-case. We consider a modification of the Quick Sort algorithm presented in class. Normally we pick a pivot at random and use it as pivot. Say that we instead we insert a step to calculate the median-of-medians (say, using groups of 5) and use that as pivot instead. In other words, Modified Quick Sort is: 1. Group the n elements in the array in groups of 5. Compute the median for each group 2. Let m be the median-of-medians 3. Partition input array around the meclian-of-medians 4. Execute Modified Quick Sort on the two sub arrays indicated by the partition (a) After step 3, what are the possible positions that m can have? (b) Write the recursion for the run time of the algorithm, incorporating IRVs where needed. Explain briefly why your recursion is correct. (c) What is the run time of the algorithm? For this question and this question only) you need not fully solve the recurrence. Just justify your answer with a few sentences Make sure to specify if you mean worst case or expected worst-case
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
