how would I go about finding the median of a set of numbers that the user enters? I posted something about a bubble sort ... but is there an easier way? thanks.
SnoFinK
Printable View
how would I go about finding the median of a set of numbers that the user enters? I posted something about a bubble sort ... but is there an easier way? thanks.
SnoFinK
A better way would be to chose a better sort algorithm such as
qsort, then sort.
Assuming that your data is x_1 ... x_n with x_i < x_{i+1}
if n is even then
median = x_{n/2} + x_{n/2 + 1}
else
median = x_{(n + 1)/2}