Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Assume you execute quicksort. Assume it turns out that at the odd levels of recursive calls you get medium lucky and partition on the

image text in transcribed

1. Assume you execute quicksort. Assume it turns out that at the odd levels of recursive calls you get medium lucky and partition on the [n/4]th smallest element. At the even levels you get very lucky and partition on the median element. For example, let's say n = 5. The first pivot will be at index 2, leaving arrays of sizes 1 and 3. It will take four comparisons. The size 1 array will take no more comparisons. In the size 3 array you will pivot on median (i.e. second) element, giving two more comparisons. Overall, this will take 4 + 2 = 6 comparisons. Analyze how many comparisons this lucky version of quicksort does. Just get the exact value for the high order term. You do not have to worry about floors and ceilings and you can make reasonable simplifying assumptions. 1. Assume you execute quicksort. Assume it turns out that at the odd levels of recursive calls you get medium lucky and partition on the [n/4]th smallest element. At the even levels you get very lucky and partition on the median element. For example, let's say n = 5. The first pivot will be at index 2, leaving arrays of sizes 1 and 3. It will take four comparisons. The size 1 array will take no more comparisons. In the size 3 array you will pivot on median (i.e. second) element, giving two more comparisons. Overall, this will take 4 + 2 = 6 comparisons. Analyze how many comparisons this lucky version of quicksort does. Just get the exact value for the high order term. You do not have to worry about floors and ceilings and you can make reasonable simplifying assumptions

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

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions