Gabriel Genellina wrote: > At Thursday 12/10/2006 17:44, [EMAIL PROTECTED] wrote: > >> > > > fun median { >> > > > var x = 0. >> > > > while( *p++) { >> > > > if( (*p) > x) x = *p. >> > > > } >> > > > return x. >> > > > } >> >> clearly, i've forgotten the definition of the median of a list. >> to that i plead faulty memory. > > That explains all. Finding the median in an efficient way (that is, > without sorting the data first) isn't trivial, so your claim of "I can > do that using only one temp variable" was a bit surprising... > BTW, the median is the value which sits just in the middle of the list > when ordered: median(3,5,12,1,2)=median(1,2,3,5,12) = 3
note that both his proposals does indeed find the median if given a list of zeros, though. maybe they just used lousy sample data in that stat class he took? </F> -- http://mail.python.org/mailman/listinfo/python-list