Writing a Faster Sorting Algorithm
21–30 of 35 posts
Re: Writing a Faster Sorting Algorithm
#22Neat algorithm, but it is largely comparing apples to oranges. std::sort is universal, ska_sort is not: > Another problem is that I’m not sure what to do for data that I can’t sort. For example this algorithm can not sort a vector of std::sets > Another problem is that right now there can only be one sorting behavior per type. You have to provide me with a sort key, and if you provide me with an integer, I will sort…
Re: Writing a Faster Sorting Algorithm
#23Every sort algorithm should take locality of data-access into account. Without this, a comparison to other algorithms may not be fair.
Re: Writing a Faster Sorting Algorithm
#24Neat algorithm, but it is largely comparing apples to oranges. std::sort is universal, ska_sort is not: > Another problem is that I’m not sure what to do for data that I can’t sort. For example this algorithm can not sort a vector of std::sets > Another problem is that right now there can only be one sorting behavior per type. You have to provide me with a sort key, and if you provide me with an integer, I will sort…
Re: Writing a Faster Sorting Algorithm
#25Neat algorithm, but it is largely comparing apples to oranges. std::sort is universal, ska_sort is not: > Another problem is that I’m not sure what to do for data that I can’t sort. For example this algorithm can not sort a vector of std::sets > Another problem is that right now there can only be one sorting behavior per type. You have to provide me with a sort key, and if you provide me with an integer, I will sort…
Do you know of any resource which details these faster algorithms when given extra requirements?
https://en.wikipedia.org/wiki/Radix_sort
The O(n log n) lower bound is only for comparison based sorts. If you don't take a comparison function, but instead look at the internal structure, you can do better, but of course that depends on that internal structure and what order you want them in.
Re: Writing a Faster Sorting Algorithm
#26Neat algorithm, but it is largely comparing apples to oranges. std::sort is universal, ska_sort is not: > Another problem is that I’m not sure what to do for data that I can’t sort. For example this algorithm can not sort a vector of std::sets > Another problem is that right now there can only be one sorting behavior per type. You have to provide me with a sort key, and if you provide me with an integer, I will sort…
With some generic programming, even complex data can be radix sorted in linear time. Google the Discriminator papers of Fritz Henglein.
Re: Writing a Faster Sorting Algorithm
#27Re: Writing a Faster Sorting Algorithm
#28Unless it uses the same interface (aka call a comparator for each eval) it's apples to oranges. I also didn't see comparisons vs swaps enumerated, which matter for complex data structures or complex comparators.
Re: Writing a Faster Sorting Algorithm
#29There the total number of elements are n and the average size of a partition is m. Then you need only apply any O(log(m)) algorithm to each partition to sort everything. That multiplies the time complexity by n/m. Then substitute n = m^c and the sort becomes O(n/c*log(n)) time. That gives you a factor of c speed up on what would otherwise be an O(nlogn) operation.
This trick is usable when you want to sort a B-Tree like structure where the data in each node is unsorted, but the nodes themselves are sorted. The file system hierarchy on a machine is like that. The default output of zfs list is also like that.
Re: Writing a Faster Sorting Algorithm
#30Earlier quoted context omitted.
AFAIK the STL is free to use any algorithm they want as long as it's O(n log n).
This is correct. The C++ standard specifies that sort must have a big-O complexity of n log(n). This can be seen on pdf page 925 of this working draft from 2014 [1]. [1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n429...
The standard doesn't seem to say "or better" here, but I know that in other places it does (or least used to say something similar).