Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

( 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.
image text in transcribed

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago

Question

4. What will the team agreement contain?

Answered: 1 week ago