by wfunction · 12y ago · 0 comments
https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-...
Do you know what the time complexity of their merging algorithm is?
As a side note, an optimal merging algorithm is in the paper called "On Optimal and Efficient in Place Merging", and it's too complicated for me to expect it in a standard library implementation. (Although the STL doesn't need to be optimal, I think the sub-optimal linear-time algorithms are also complicated enough to not be used for the standard library, but correct me if I'm wrong.)
> Complexity: It does at most N log^2(N) (where N == last - first) comparisons; if enough extra memory is available, it is N log(N).