Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Let A and B be two sorted arrays, each array consists of n real numbers in ascending order. Give an algorithm, running in O(log
4. Let A and B be two sorted arrays, each array consists of n real numbers in ascending order. Give an algorithm, running in O(log n) time, to compute the median of the elements formed by the union of the elements in both the arrays. (You may assume that the union consists of 2n distinct real numbers.) Hint: Assume that the median element is from A, and assume that it is at index i. Then for r = A[i] to be the median element, you can say something about how many elements in B need to smaller than r and that can be checked in O(1) time. The problem to solve here is how fast you can search for z in A? 4. Let A and B be two sorted arrays, each array consists of n real numbers in ascending order. Give an algorithm, running in O(log n) time, to compute the median of the elements formed by the union of the elements in both the arrays. (You may assume that the union consists of 2n distinct real numbers.) Hint: Assume that the median element is from A, and assume that it is at index i. Then for r = A[i] to be the median element, you can say something about how many elements in B need to smaller than r and that can be checked in O(1) time. The problem to solve here is how fast you can search for z in A
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started