Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose in quicksort, we have access to an algorithm which chooses a pivot such that, the ratio of the size of the two subarrays divided

image text in transcribed

Suppose in quicksort, we have access to an algorithm which chooses a pivot such that, the ratio of the size of the two subarrays divided by the pivot is a constant k. i.e an array of size n is divided into two arrays, the first array is of size ni nk and the second array is of size n2 = so that the ratio ni = k a constant. n k+1 k+1 n2 (a) (b) Given an array, what value of k will result in the best partitioning? Write down a recurrence relation for this version of QuickSort, and solve it asymptotically using recursion tree method to come up with a big-O notation. For this part of the question assume k = 3. Show your work, write down the first few levels of the tree, identify the pattern and solve. Assume that the time it takes to find the pivot is (n) for lists of length n. Note: Remember that a big-O bound is just an upper bound. So come up with an expression and make arguments based on the big-O notation definition. Does the value of k affect the running time? (c)

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

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions