Question: In data smoothing applications, such as in visualizing trends in stock averages over time, it is useful to keep track of the median of a

In data smoothing applications, such as in visualizing trends in stock averages over time, it is useful to keep track of the median of a set, S, of numbers as values are inserted or removed from S. Describe a method for maintaining the median of an initially empty set, S, subject to an operation, insert(x), which inserts the value x, and an operation, median(), which returns the median in S. Each of these methods should run in at most O(log n) time, where n is the number of values in S.

Step by Step Solution

3.49 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Keep track of the median in a variable m Maintain ... View full answer

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 Data Structures Algorithms Questions!