Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please help in C code: The median of a dataset of integers is the midpoint value of the dataset for which an equal number of
Please help in C code:
The median of a dataset of integers is the midpoint value of the dataset for which an equal number of integers are less than and greater than the value. To find the median, you must first sort your dataset of integers in non-decreasing order, then: If your dataset contains an odd number of elements, the median is the middle element of the sorted sample. In the sorted dataset (1,2,3}, 2 is the median. If your dataset contains an even number of elements, the median is the average of the two middle elements of the sorted sample. In the sorted dataset (1,2,3,4}, 2.5 is the median. 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 (i.e., for the first element through the element). 3. Print the list's updated median on a new line. The printed value must be a double-precision number scaled to decimal place (i.e., format). Input Format The first line contains a single integer, n, denoting the number of integers in the data stream. Each line i of the n subsequent lines contains an integer, a, to be added to your list.
Step by Step Solution
★★★★★
3.22 Rating (157 Votes )
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