Question: Use Java: Problem 1: Given two sorted arrays each of size n. Find the median of an array resulting from merging the two arrays. (Hint:

 Use Java: Problem 1: Given two sorted arrays each of size

Use Java: Problem 1: Given two sorted arrays each of size n. Find the median of an array resulting from merging the two arrays. (Hint: You use the same approach of binary search algorithm. The time complexity of your solution should be 0(logn).) (Example 1: a1 - [0, 2, 10, 26, 68], > median- 10 a2- [1, 11, 18, 20, 41], >> median 18 OUTPUT: Median -(11+18/2-14.5) (Example 2: a1 [5, 6, 14, 26], >> median = (6+14)/2-10 a2 = [3, 41, 88, 100] >> median (41+88)/2 = 64.5 OUTPUT: Median (14+26)/2 - 20) (Example 3: a1 - [5, 10], a2 = [2, 41] OUTPUT : Median fmax(a1[0], a2[0] + min(a1[1], a2[1]))/2 = {max(5,2)+min (10,41))/2 = 5+10)/2- 7.5 ) Problem 2: Given a sorted array of n distinct numbers where the range of the numbers are between 0 to m and m>n (m is given by user). Find the smallest missing numbers. (Hint: You should use the same approach of binary search algorithm. The time complexity of your solution should be O(logn).) (Example 1: a - [0,1,3,8,9], m-10 OUTPUT: 2) (Example 2: a - [2,5,7,11], m - 15 OUTPUT: e ) (Example 3: a - [0,1,2,3,4], m-8 OUTPUT: 5 ) (Example 4: a [12], m = 13 OUTPUT: e)

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!