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 oneby-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

OCA Oracle Database SQL Exam Guide Exam 1Z0-071

Authors: Steve O'Hearn

1st Edition

1259585492, 978-1259585494

Students also viewed these Databases questions

Question

What are the different stages in a companys lifecycle?

Answered: 1 week ago

Question

Lo6 Identify several management development methods.

Answered: 1 week ago