Worse is better. Is there an example?
Posted
by J.F. Sebastian
on Stack Overflow
See other posts from Stack Overflow
or by J.F. Sebastian
Published on 2009-01-23T01:35:32Z
Indexed on
2010/03/18
9:41 UTC
Read the original article
Hit count: 542
Is there a widely-used algorithm that has time complexity worse than that of another known algorithm but it is a better choice in all practical situations (worse complexity but better otherwise)?
An acceptable answer might be in a form:
There are algorithms
A
andB
that haveO(N**2)
andO(N)
time complexity correspondingly, butB
has such a big constant that it has no advantages overA
for inputs less then a number of atoms in the Universe.
Examples highlights from the answers:
Simplex algorithm -- worst-case is exponential time -- vs. known polynomial-time algorithms for convex optimization problems.
A naive median of medians algorithm -- worst-case O(N**2) vs. known O(N) algorithm.
Backtracking regex engines -- worst-case exponential vs. O(N) Thompson NFA -based engines.
All these examples exploit worst-case vs. average scenarios.
Are there examples that do not rely on the difference between the worst case vs. average case scenario?
Related:
The Rise of ``Worse is Better''. (For the purpose of this question the "Worse is Better" phrase is used in a narrower (namely -- algorithmic time-complexity) sense than in the article)
-
The ABC group strived for perfection. For example, they used tree-based data structure algorithms that were proven to be optimal for asymptotically large collections (but were not so great for small collections).
This example would be the answer if there were no computers capable of storing these large collections (in other words large is not large enough in this case).
Coppersmith–Winograd algorithm for square matrix multiplication is a good example (it is the fastest (2008) but it is inferior to worse algorithms). Any others? From the wikipedia article: "It is not used in practice because it only provides an advantage for matrices so large that they cannot be processed by modern hardware (Robinson 2005)."
© Stack Overflow or respective owner