Most viewed recipes tagged "minmax"http://code.activestate.com/recipes/tags/minmax/views/2011-10-22T18:40:32-07:00ActiveState Code RecipesFast min/max function (Python)
2011-10-22T18:40:32-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/577916-fast-minmax-function/
<p style="color: grey">
Python
recipe 577916
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/minmax/">minmax</a>, <a href="/recipes/tags/sorting/">sorting</a>).
</p>
<p>Minimizes the number of comparisons to compute the minimum and maximum of a dataset. Uses 1.5 compares for every element, improving on the more obvious solution that does 2 comparisons per element.</p>