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,...
-
Determine a state variable model for the circuit shown in Figure P3.22. The state variables are x1 = i, x2 = v1, and x3 = v2. The output variable is v0(t). 12 Output FIGURE P3.22 RLC circuit.
-
A compressor uses air as the working fluid. The air enters at 101 kPa and 16 C and exits at 1.86 MPa and 775 C. What is the compressor isentropic efficiency?
-
A partially polarized thermal light wave is incident on a photodetector. The total incident integrated intensity can be regarded to consist of two statistically independent components, \(W_{1}\)...
-
Hesselwood Companys market research division has projected a substantial increase in demand over the next several years for one of the companys products. To meet this demand, the company will need to...
-
You decide to take your car on a drive through Canada, where gas is sold in liters and distances are measured in kilometers. Suppose your car's gas efficiency is 24.82 mi/gal . How many liters of gad...
-
Alfonso Inc. acquired 100 percent of the voting shares of BelAire Company on January 1, 2020. In exchange, Alfonso paid $198,000 in cash and issued 100,000 shares of its own $1 par value common...
-
Identify the compound(s) that is(are) insoluble in water: Identify the compound(s) that is(are) amino acids: Identify the compound(s) that is(are) monosaccharides: Identify the compound(s) that...
-
Kaylin Marcotte was putting in long hours at the Skimm, a media startup, and needed a way to unwind. She was on screens all day and wanted to do something with her hands. She hit upon puzzles and...
-
A material is required for a heat exchanger for cooling a small marine engine, saline, water at \(120^{\circ} \mathrm{C}\) (and thus under pressure). List function and constraints, set the objective...
-
Consider a flat plate mounted in the test section of a supersonic wind tunnel. The plate is at an angle of attack of \(10^{\circ}\) and the static pressure on the top surface of the plate is \(1.0...
-
A material is required to manufacture office scissors. Paper is an abrasive material, and scissors sometimes encounter hard obstacles like staples. List function and constraints, set the objective to...
-
Formulate the constraints and objective you would associate with the choice of material to make the forks of a racing bicycle.
-
(A simplified hedging example) In the early 2000's, there was a casino boom in Macao. To compete with other players in the market, some casinos offered free lunch boxes to those customers who kept...
-
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,...
-
Most countries in Europe do not have stringent laws to protect whistleblowers. True/false
-
In view of significant financial losses to investors, corporate fraud does not really affect the U.S. economy and investor confidence. True/false
-
The National Crisis Inquiry Report (2011) concluded that the financial crisis was unavoidable. True/false
Study smarter with the SolutionInn App