Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Students also viewed these Databases questions

Question

What are our strategic aims?pg 87

Answered: 1 week ago

Question

7. Senior management supports the career system.

Answered: 1 week ago