Question: 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 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

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!