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
![first element of the array as a pivot. ALGORITHM quicksort (A[O..n-1]) 1/Input:](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3a0eeb06d3_47866f3a0ee459b6.jpg)

![ascending order if n > 1 pivot + A[0] copy the elements](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3a0efebf6e_47966f3a0ef835c1.jpg)
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
Get step-by-step solutions from verified subject matter experts
