Question: ( 3 0 pts . ) Median Heaps. Consider an array of N numbers x 1 , x 2 , dots, x N that you

(30 pts.) Median Heaps. Consider an array of N numbers x1,x2,dots,xN that you will be receiving one-
by-one in a single pass (i.e., as a stream of numbers). You are not allowed to re-query previous numbers.
Design an effective data structure involving one or more heaps that, after receiving the n-th number, reports
the median of the numbers x1,x2,dots,xn, observed so far. The time complexity of your algorithm should be
O(logn) per number received in the worst case. For simplicity, assume there are no duplicates in the stream.
Explain the algorithm/data structure, running time, and correctness.
Hint: If n is odd, the median of the data stream x1,x2,dots,xn is the middle element of the sorted data stream,
else the median is the average of the middle two elements of the sorted data stream.
 (30 pts.) Median Heaps. Consider an array of N numbers x1,x2,dots,xN

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!