Question: Problem 4. (14 marks) Given an unsorted array A of n elements that can be totally sorted, and an integer 1-k-n, the Selection problem is

 Problem 4. (14 marks) Given an unsorted array A of nelements that can be totally sorted, and an integer 1-k-n, the Selection

Problem 4. (14 marks) Given an unsorted array A of n elements that can be totally sorted, and an integer 1-k-n, the Selection problem is to find the element x st. #{y A : y = k. If we assume all elements in A are unique (which you may assume for the rest of the question), then your goal is to return the unique element which is strictly greater than exactly k -1 other elements and strictly smaller than exactly n - k other elements. Note that you cannot assume k is constant. A common application of the Selection problem is to set k and return the median of the elements in A The following procedure DSelect is a deterministic algorithm for the Selection problem. DSelect(A, p, r, k) if (r-p k) then eturn DSelect(A,p, (s-1),k) if (inder k) then eturn DSelect(A,p, (s-1),k) if (inder

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!