Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A typical version of quick-sort is stated below. It selects the first element of the array as a pivot. ALGORITHM quicksort (A[O..n-1]) 1/Input: an array

image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
A typical version of quick-sort is stated below. It selects the first element of the array as a pivot. ALGORITHM quicksort (A[O..n-1]) 1/Input: an array A[0..n-1) of n numbers 1/output: the array A sorted in ascending order if n > 1 pivot + A[0] copy the elements of A smaller than pivot to si copy the elements of A equal to pivot to S2 copy the elements of A larger than pivot to ss quicksort (S) quickSort (Sa) copy the elements back into A in order: first insert the elements of s, then those of S2, and finally those of Ss. Consider a modified version of quick-sort which differs from the typical version by a single line (it is underlined): the pivot is selected as the median in the current array. ALGORITHM quickSort-modified (A[0..n-1]) 1/Input: an array A[o..n-1] of n numbers //Output: the array A sorted in ascending order if n > 1 pivot + median (A) copy the elements of A smaller than pivot to Si copy the elements of A equal to pivot to S2 copy the elements of A larger than pivot to Sz quickSort-modified (SI) quickSort-modified (S3) copy the elements back into A in order: first insert the elements of Su, then those of S2, and finally those of S. Questions 3.1-3.2 deal with the worst-case complexity analysis of quickSort-modified. Q3.1 3 Points Suppose function median performs the number of comparisons which depends linearly on the array size. We can estimate the number of comparisons C(n) performed by quickSort-modified as C(n) 2, where D is some positive constant, C(n) = 1, if n

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

KEY QUESTION Refer to Figure 3.6, page

Answered: 1 week ago