Implement a function called median
which takes as input a sequence (e.g. a list or a tuple) of values and returns the median of the data values.
For a sorted sequence x
with N
data points, the median is defined as follows:
x
For instance, if x=[1, 2, 3, 4, 5]
the median of x should be 3.
If x=[1, 2, 3, 4]
, its median would be (2+3)/2
.