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.)
I think it's interesting how choice of data structure affects algorithm characteristics.
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...
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
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.