This entry was posted on Tuesday, October 13th, 2009 at 5:47 am and is filed under Design, Mathematics, algorithms, data structures, hacks, programming, theoretical computer science. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
November 6, 2009 at 19:05 pm |
I enjoyed this blog post. Until now, I haven’t heard of Cargo Cult, but I did experience the phenomena.
I believe that algorithm implementation can be hidden behind interfaces, especially in c++. I would consider using a typedef definition of std::*map into my own map-name. Then, when the application is complete I would be able to benchmark both algorithms.
November 7, 2009 at 1:23 am |
We all have experienced this in some fashion, I think. It is especially true of things that are incompletely understood like, say, hash tables. Hash tables are a good example of this. I hear again and again that the hash table size must be a prime number. Well, ok, but only if you’re using quadratic residue secondary search (and it has to be a
prime, a result due to Maurer, I think). Otherwise the size doesn’t really matter, it just has to be sparse enough.
Yes, you should be able to hide such details as the actual container behind an interface. Better yet, in C++, you should be able to use templates/metaprogramming to switch between containers. Alas, the STL isn’t quite container-agnostic (a major shortcoming in my opinion) so it prooves rather tricky to get this right. Indeed, not all containers implement operator[], and not all iterator return the same thing; some return a pointer, some a pair.