Question: You are given two sorted arrays A and B each containing n distinct integers and a natural number r < = 2 n as input.

You are given two sorted arrays A and B each containing n distinct integers and a natural number r <=2n as input. Assume that there is no common element in A and B. Let C be set of all elements either in A or B (that is C is union of A and B). For an element p in array C rank(p) in C is a total number of elements in C which are less than or equal to p.(E.g. if C ={2,7,1,9) then rank(7) in C is 3 as elements 1,2,7 in C are less than or equal to 7). Give an efficient algorithm to find an element p in C with rank(p)= r. Give proper Pseudo-code for the algorithm. Analyze the time complexity of the algorithm.

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!