Randal writes:
=> If you need only the best (or worst) of the list, a sort is probably
=> overkill. Just do a "high-water mark" scan, keeping the best
=> candidate as you compare it with each other candidate.
For fixed (but arbitrarily large) K, it is possible to find
the K smallest or K largest elements of an N-element list in
O(N) time. Cormen/Leiserson/Rivest's Algorithms book had the
solution to this task. I can look up the page numbers if
someone cares.
As always, though, it is a tradeoff between programmer and machine
efficincies.
peace, || Barefoot, female, solar engineers:
--{kr.pA} || http://tinyurl.com/4ra8
--
ledgerdemain, n.: Sleight of hand in preparing the balance sheet.