Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions