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).
I think it's interesting how choice of data structure affects algorithm characteristics.
1. Yes, merge sort is exactly the kind of algorithm you'd use for sorting linked lists
2. No, sorting linked lists is not the primary application of merge sort
For sure, if it doesn't make sense to use a linked list in the first place then linked list merge sort definitely doesn't make sense...
Absolutely. I'm not even sure how you would do such a thing.
I personally have found it interesting when considering the difference between an array of pointers and a linked list, simply because they both have the same overhead but one doesn't require allocating any more memory for a merge sort.
I basically agree with what you say (maybe bar it not being useful knowledge) but I don't think it's worth continuing trying to clarify my initial statement.
Article said they got 2.2x improvement using their parallel method compared to STL. Trade off was having 100% CPU utilization vs 12.5% with STL.
Or let x be time we need to complete the task:
12.5 * x first (load over time) is less than second 100 * x / 2.2 for the same x.
Or is this an inaccurate comparison?
GPUs are way more parallel, and faster than this too. "clocks about 100x faster than calling std::stable_sort on an i7 Sandy Bridge" http://nvlabs.github.io/moderngpu/mergesort.html
I'm saying their merge sort was likely not actually in-place.