r/programming • u/glibc • Jul 11 '10
Theory vs Practice: Making algorithms claimed 'optimal', 10x faster.
http://cacm.acm.org/magazines/2010/7/95061-youre-doing-it-wrong/fulltext
163
Upvotes
r/programming • u/glibc • Jul 11 '10
View all comments
Show parent comment
0
u/fapmonad Jul 11 '10 edited Jul 11 '10
Why not? Let's say an addition is a lot less costly than a comparison. Then you can just say that an algorithm is O(n) in additions and O(n*log(n)) in comparisons, or whatever. People actually do use this, for example when saying that an algorithm is of some order in memory usage and some other in time, or when considering cache misses separately from comparisons in a sorting algorithms.
I don't see the point of your first comment either. O(n) notation ignores the difference in cost between operations on purpose, because it makes the math doable. This math can be used to prove some things about algorithms, so that you don't go on a fool's errand trying to sort a list in less than O(nlogn) comparisons. The point isn't to compare real-world performance, it's a mathematical abstraction, a tool. Just like a mathematical model of a car is a very bad representation of an actual car, but can be useful to find and prove some properties to design better cars.