Nice and interesting article, however I don't really agree with the following statement:
"For example, the search algorithms in the C++ Standard are O(log(N)) when used with random-access iterators, but O(N) when used with input iterators."
What I know about the C++ search algorithms is rather different:
A) std::search() original complexity: O(N*M) [1]
Implementations with better complexity have been presented [4] but not yet adopted by the most notable STL implementations. [7,8,9]
B) std::search_n() original complexity: O(N*m) - O(N) [2]
A search_n specialization for random access iterators has been presented in the year 2004 [5] and has been soon adopted by some STL implementors. [7,8] Another STL implementor has also adopted a similar search_n specialization a little later. [9]
C) std::find_first_of() original complexity: O(N*M) [3]
A find_first_of specialization for one-byte integers has been presented in the year 2007 and has been soon adopted by one STL implementor. [8]
References:
1. The std::search STL algorithm
http://www.sgi.com/tech/stl/search.html2. The std::search_n STL algorithm
http://www.sgi.com/tech/stl/search_n.html3. The std::find_first_of STL algorithm
http://www.sgi.com/tech/stl/find_first_of.html4. David R. Musser and Gor V. Nishanov, "A Fast Generic Sequence Matching Algorithm",
Rensselaer Polytechnic Institute Computer Science Technical Report 97-11 (without appendices, 1997);
full version available at:
http://www.cs.rpi.edu/~musser/gp/gensearch1.pdf (revised Feb. 2, 2001).
5. Can search_n be more efficient?
http://www.codeproject.com/KB/stl/SearchN.aspx6. find_first_of: A performance pitfall among the STL algorithms
http://www.codeproject.com/KB/stl/find_first_of.aspx7. The STL shipped with the GCC-C++ compiler
http://gcc.gnu.org/libstdc++/8. The STLport STL implementation
http://stlport.sourceforge.net/9. The STL shipped with the MS-VC++ compiler
http://msdn.microsoft.com/en-us/library/ct1as7hw(VS.80).aspx
Best regards
Jim Xochellis
Homepage:
http://geocities.com/jimxoch/