How should Pythons statistics.median be implemented? -
in new python 3.4, introduced new statistics module. among other things has function calculate median.
currently function first sorts data determine median. if @ source code contains remark:
# fixme: investigate ways calculate medians without sorting? quickselect?
is there faster way calculate median function using? algorithm should python implement determining median?
you use min-max-median heap find min, max , median in constant time (and take linear time build heap). if want know more using heaps media, read here min-max heaps
here example code in python
Comments
Post a Comment