Question
**In C++** The median of a set of integers is the midpoint value of the data set for which an equal number of integers are
**In C++**
The median of a set of integers is the midpoint value of the data set for which an equal number of integers are less than and greater than the value. To find the median, One way is to sort your set of integers in non-decreasing order, then: 1. If your set contains an odd number of elements, the median is the middle element of the sorted sample. 2. If your set contains an even number of elements, the median is the average of the two middle elements of the sorted sample. Given an input stream of integers, you must perform the following task for each integer:
1. Add the integer to a running list of integers.
2. Find the median of the updated list.
For example, assume a stream of 1, 4, 6, 3, 2, 8 The median would be 1, 2.5, 4, 3.5, 3,3 (Hint: use heaps)
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