Question
Application: Median Maintenance: Consider the following situation. You are presented with a sequence of numbers, one by one. Assume for simplicity they are all distinct.
Application: Median Maintenance: Consider the following situation. You are presented with a sequence of numbers, one by one. Assume for simplicity they are all distinct. Each time you receive a new number your program must respond with the median (recall the median is the middle number, if there are 11 numbers it would be the 6th smallest or if 12 then either the 6th or 7th smallest) of all numbers received so far. In the next part of the course we will see a way to determine the median of a set of n numbers in O(n) time. However in this particular situation it can be done in O(2) for each median that must be returned. Write pseudo code using heaps to solve this problem
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