Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
    
Apparently, they mentioned this common general rounding rule in order not to give away the fact that the median cannot have other fractional parts. –  Hagen von Eitzen Apr 5 '13 at 16:28
add comment

1 Answer

up vote 2 down vote accepted

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$.

share|improve this answer
    
For {1,5},wouldn't median be 5 taking into consideration the above quote..it cleary says that or am i missing something! thanks. –  Anirudha Apr 5 '13 at 16:03
    
thanks for that nice explanation –  Anirudha Apr 5 '13 at 16:22
    
You're welcome :). –  Lord_Farin Apr 5 '13 at 16:23
    
When the instructions say the "closest whole number higher value" they must mean closest integer, not closest member of the set being analyzed... –  User58220 Apr 5 '13 at 20:01
    
@user58220 Such is in exact agreement with the answer given. –  Lord_Farin Apr 5 '13 at 21:06
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.