# How to find median value for five given elements based on the max min and sum of the elements

this question occurred in my interview,

How to find the median values using the min, max, and sum values of the given 5 elements?

for eg if given 3 elements we can use sum - min - max

a = [3,6,9] here median is 6 min = 3 max = 9 sum = 18

18 - 9- 3 = 6 which is the same as median values.

so the question is how to find the median for the 5 elements?

find for the a = [1,2,3,4,10]

If you only know the min, max, and sum of the 5 numbers, you cannot determine the median. E.g.

median(1, 2, 3, 4, 5)=3
median(1, 2.1, 2.8, 4.1, 5)=2.8.

But both have (min, max, sum) = (1, 5, 15).

Find the max and min of the initial list. Create a new list without those 2 elements. Find the new max, min and sum and use the method you mentioned,

median = sum - min - max

• Or do the "throw away min and max" step twice. Jul 30, 2022 at 9:48
• This assumes knowing all five numbers, hence an ability to find the median directly, not from the max, min and sum only... Jul 30, 2022 at 13:15
• I suspect that this is the answer sought by the person originally proposing the riddle. Aug 16, 2022 at 0:07