Question: Problem 1. Suppose we have an array A[1:n) of n distinct numbers. For any element A[i], we define the rank of A[i], denoted by rank(A[i]),

Problem 1. Suppose we have an array A[1:n) of n distinct numbers. For any element A[i], we define the rank of A[i], denoted by rank(A[i]), as the number of elements in A that are strictly smaller than A[i] plus one; so rank(A[i]) is also the correct position of A[i] in the sorted order of A. Suppose we have an algorithm magic-pivot that given any array B1: m] (for any m > 0), returns an element B[i] such that m/3 q, we need to look for it in the subarray A[q+1:n] (although, what is the new rank we should look for now?). Problem 1. Suppose we have an array A[1:n) of n distinct numbers. For any element A[i], we define the rank of A[i], denoted by rank(A[i]), as the number of elements in A that are strictly smaller than A[i] plus one; so rank(A[i]) is also the correct position of A[i] in the sorted order of A. Suppose we have an algorithm magic-pivot that given any array B1: m] (for any m > 0), returns an element B[i] such that m/3 q, we need to look for it in the subarray A[q+1:n] (although, what is the new rank we should look for now?)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
