Averages/Median: Difference between revisions

Content deleted Content added
Dinosaur (talk | contribs)
Cross-reference.
Dinosaur (talk | contribs)
→‎{{header|Fortran}}: Using a supplied routine...
Line 1,274: Line 1,274:


end program Median_Test</lang>
end program Median_Test</lang>

If one refers to [[Quickselect_algorithm#Fortran]] which offers function FINDELEMENT(K,A,N) that returns the value of A(K) when the array of N elements has been rearranged if necessary so that A(K) is the K'th in order, then, <lang Fortran> K = N/2
MEDIAN = FINDELEMENT(K + 1,A,N)
IF (MOD(N,2).EQ.0) MEDIAN = (FINDELEMENT(K,A,N) + MEDIAN)/2 </lang>
As well as returning a result, the function possibly re-arranges the elements of the array, which is not "pure" behaviour. Not to the degree of fully sorting them, merely that all elements before K are not larger than A(K) as it now is, and all elements after K are not smaller than A(K).


=={{header|FreeBASIC}}==
=={{header|FreeBASIC}}==