Fractional part of Median always .5 or .0

3k Views Asked by At

If we find the mid value of two integer number,it's decimal part would always contain .5 or .0 exactly

For Example:

(5+10)/2=7 .5

(6+2)/2=4 .0

But,in some coding challenge they asked to calculate median for a list of integers

Then they said

please consider the closest whole number higher value in case the decimal is greater than or equal to 0.5 and above and the closest whole number lower value if decimal is less than 0.5

Here's the complete question!

enter image description here

Now I can't understand this particular quote?Can you help me with this?

Thanks.

1

There are 1 best solutions below

5
On BEST ANSWER

You are correct, the phrasing is awkward. They could have sufficed to say that $\frac12$ is to be rounded up.


Addendum: In response to OPs question in the comments, presume that our sample is $\{1,5\}$. Thus the first term is $1$, the second is $5$.

According to the formula above, the median is:

$$\frac{(\text{the $(2/2)$th term}+\text{the $(2/2+1)$th term})}2 = \frac{1 + 5}2 = 3$$

whence is different from the $(2/2+1)$th term, which is $5$.