4 ms·
Using an algorithm with a better average case and very bad worst case instead of an agorithm that always executes in linear time is pretty common - for example,
by zdw 16y ago
Using an algorithm with a better average case and very bad worst case instead of an agorithm that always executes in linear time is pretty common - for example, in grep:
http://ridiculousfish.com/blog/archives/2006/05/30/old-age-and-treachery/ http://ridiculousfish.com/blog/archives/2006/05/30/old-age-a...
Makes sense, as long as you and the people using the code know the tradeoffs involved.