Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Dual-pivot Quicksort. In class, we looked at the randomized version of quicksort algorithm where we choose the pivot uniformly at random (i.e. an element

image text in transcribed
3. Dual-pivot Quicksort. In class, we looked at the randomized version of quicksort algorithm where we choose the pivot uniformly at random (i.e. an element in an n-element array is chosen to be the pivot with probability 1). Consider a variant of the randomized quicksort algorithm where instead of choosing one pivot uiformly at random, we would instead choose tuo pivots 2 1 and 22 uniformly at random (we call this dual-pivot quicksort') We then partition the array around these two pivots in the following way: 1st Pivot 2nd Pivot and sr2 (a) (4 points) What would be the recurrence and running time of the algorithm if we always choose the 1st pivot to be the minimum element and the 2nd pivot to be the maximum element (i.e. the worst-case input and random choices)? (b) (4 points) What would be the recurrence and running time of the algorithm if we always choose the two pivots such that the array would be partitioned into three equally-sized sub-arrays (i.e. the best-case input and random choices)? (c) (2 points) As is the case with the single-pot quicksort algorithm, we can prove that the expected running time of dual-pivot quicksort is (n lg n). Explain in your own words what we mean by expected running time (i.e, what kind of inputs is this analysis escribing?) 3. Dual-pivot Quicksort. In class, we looked at the randomized version of quicksort algorithm where we choose the pivot uniformly at random (i.e. an element in an n-element array is chosen to be the pivot with probability 1). Consider a variant of the randomized quicksort algorithm where instead of choosing one pivot uiformly at random, we would instead choose tuo pivots 2 1 and 22 uniformly at random (we call this dual-pivot quicksort') We then partition the array around these two pivots in the following way: 1st Pivot 2nd Pivot and sr2 (a) (4 points) What would be the recurrence and running time of the algorithm if we always choose the 1st pivot to be the minimum element and the 2nd pivot to be the maximum element (i.e. the worst-case input and random choices)? (b) (4 points) What would be the recurrence and running time of the algorithm if we always choose the two pivots such that the array would be partitioned into three equally-sized sub-arrays (i.e. the best-case input and random choices)? (c) (2 points) As is the case with the single-pot quicksort algorithm, we can prove that the expected running time of dual-pivot quicksort is (n lg n). Explain in your own words what we mean by expected running time (i.e, what kind of inputs is this analysis escribing?)

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

OSer que el P. V.I. = = 1 tendr solucin nica? Expiica.

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago