I used med sorted fares for this exercise and my output was 43.8.
The solution utilises sortedFares [`long$(count sortedFares)%2] with an output of 43.9.
The solution formula also appears to look like a median calculation. Can anyone advise why they differ and why the solution answer is the accurate one pls? Thanks
Hi @natasha-lakhpaty the indexing approach taken in the exercise solution returns the value at the index that is halfway between the sorted list.
The med function doesn't have to return an actual distinct value that exists in the list, but instead the arithmetic middle value. Have added a simpler example here - hope this helps!
hi I understand now. In the case of middle values that are 2 values (ie where in the case of the median an average would be found) which middle value will the query result in- the first or the second?