Median Bug


#1

There is a problem with the checking program!
When I submit they say that when List [4,5,5,4] is entered 5.0 is returned and not 4.5, however, the median of this list is 5.0 because the centre two entries are 5 and 5 thus the median will be 5, because it is the average between 5 and 5.

I can't find the link to submitting bugs, thus I have started a topic, hopefully, this can be fixed so that I can continue!


#2

no, there is not.

the median is the two center entries of a sorted list, so after sorting you have:

[4,4,5,5]

two middle values are 4 and 5, which makes the median 4.5


#3

Thanks, forgot the sorting !


#4

The median of [4,5,5,4] is actually 4.5. The list should be sorted first, before we look for what is in the middle.


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.