Question: (4) Implementation of the following algorithm to find the i-th smallest element of a given list Input: a list of integers - A, and an

(4) Implementation of the following algorithm to find the i-th smallest element of a given list Input: a list of integers - A, and an integer j Output: an integer Example: A 3(11, 58,-3, 100, 2000), 1 xit returns 11 (the 2nd smallest element in A) 1: L2 : 3: 4 : L5: // divide A into sublists of den 5 sublists A'daj+5] for j in range(0, len(A), medians= [sorted(sublist) [den(sublist)/2] for if len(medians)(s5 then 5)] sublist in sublists] pivot sorted(medians) [len(medians)/2] L6 : else //the pivot is the median of the medians pivot = Usdian.of..nedians(medians, den(medians)/2) 7: 8: L9 : //partitioning step low = [j for j in A if j pivot] L10 : k-len(low) return Uledan.ot.medians(loui) return median.of wedians (bigh.i-k-1) return ALpivot] else if >k: 12 : L13: L14: else // #pivot k Requirements . Implementation of the above algorithm using any programming language of your choice. . What is the time complexity of the algorithm median of nedians? Explain it by using master theorem on its recurrence function. *Run the 100 worst cases of input sizes of 10, 104, and 106 of algorithm Find-ith-via-Quicksort compare the total running times with total running times using median of medians
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
