Please help in C code: The median of a dataset of integers is the midpoint value of
Fantastic news! We've Found the answer you've been seeking!
Question:
Please help in C code:
Transcribed Image Text:
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. 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.
Expert Answer:
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
Write a program that prompts the user for four 32-bit integers, stores them in an array, calculates the sum of the array, and displays the sum on the screen. The program also display the smallest and...
-
Please write a C Code for this problem. Please do not submit C++ or Python Code.
-
Please help with this code all the requirements are in the attached image. Add the requirements into the code provided below. HTML: My Movie Library Title: Genre: Action Adventure Comedy Documentary...
-
Our model of pollution in this chapter assumed that emissions are a pure private bad, and that people have no ability to protect themselves from the adverse consequences of exposure. In reality,...
-
A sport utility vehicle with a thermal efficiency (th) of 20% produces 250 hp of engine output while traveling at a velocity of 80 mph. (a) Determine the rate of fuel consumption in kg/s if the...
-
Additional information: a. Annual depreciation of the equipment; $11,500. b. $12,000 of the Prepaid Insurance balance has expired. c. Unbilled and unrecorded revenues at year-end totalled $31,000....
-
Montgomery [2020] presents an experiment concerning the tensile strength of synthetic fiber used to make cloth for men's shirts: The strength is thought to be affected by the percentage of cotton in...
-
Consider the following activities and their durations. The original project schedule, using early activity starts, is shown in Figure 11.20. Reconfigure the network using critical chain project...
-
Let the S&P 500 index have: S 0 = $ 2,500 \sigma = 35% \delta = 2% continuously compounded r= 4% What is the price of a bond that after 2 years pays S 0 + max(0, S 2 S 0 )?
-
You have sent confirmations to 40 customers of Berg Shovick Express, a long-time audit client experiencing some financial difficulty. The company sells specialized high-technology goods. You have...
-
Prove that: tan +X 4 tan -X 4 1+tan x 1-tan x
-
Here are a number of questions which are meant to stimulate thinking and should be illuminated by web search and open access journals. (a) Why is synchronisation a problem in finance (herding), the...
-
This project is concerned with the review article Connectivity and complex systems: Learning from a multi-disciplinary perspective [459]. The article is rather long, but a very detailed reading is...
-
Try to think of networks in different systems such as food webs, interconnected airports, social networks, etc. Use a web search to investigate which type of distribution the number of links attached...
-
In a previous poll, \(29 \%\) of adults with children under the age of 18 reported that their family ate dinner together seven nights a week. Suppose that, in a more recent poll, 318 of 1157 adults...
-
(a) Determine the critical value(s) for a right-tailed test of a population mean at the \(\alpha=0.01\) level of significance with 15 degrees of freedom. (b) Determine the critical value(s) for a...
-
Determine the running time of the following algorithms. Write summations to represent loops and simplify. Justify your solution. When using upper and lower bounds, be sure to justify both the upper...
-
Determine two different Hamilton circuits in each of the following graphs. A B F G
-
Verify Equation (1.2).
-
Let U denote a random variable uniformly distributed over (0, 1). Compute the conditional distribution of U given that (a) U > a; (b) U < a; where 0 < a < 1.
-
Suppose that a biased coin that lands on heads with probability p is flipped 10 times. Given that a total of 6 heads results, find the conditional probability that the first 3 outcomes are (a) h, t,...
-
Who was Phar-Mors flamboyant Chief Executive Officer?
-
Which of the following generally is not considered something of value? 1. Cash, money or checks 2. Airline miles or hotel credits associated with frequent activity (e.g., frequent flier miles) 3. An...
-
Which of the following is not one of the five major categories of fraudulent disbursements? 1. Payroll schemes 2. Expense reimbursement schemes 3. Shell company schemes 4. Billing schemes
Study smarter with the SolutionInn App