Question: Median - of - 3 - Quicksort ( A [ 1 : n ] , n ) Input: An array A [ 1 : n

Median-of-3-Quicksort( A[1 : n], n ) Input: An array A[1 : n] of n distinct numbers. Output: A[1 : n] with its numbers sorted in increasing order of value. 1. if n =2 then 2. if A[2]< A[1] then swap A[1] and A[2]3. elseif n >2 then 4. x median of A[1], A[2] and A[3]5. rearrange the numbers of A[1 : n] such that (i) A[k]= x for some k in [1, n],(ii) A[i]< x for each i in [1, k 1], and (iii) A[i]> x for each i in [k +1, n],6. Median-of-3-Quicksort( A[1 : k 1], k 1)7. Median-of-3-Quicksort( A[k +1 : n], n k )8. return

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 Programming Questions!