post  sorting method

mbahdoekon (2)   Link to this post
how much sorting method in c++??(5 is enough)
and give the explanation please..help!
Bazzy (4120)   Link to this post
how much sorting method in c++??(5 is enough)
What?

http://www.cplusplus.com/reference/algorithm/sort/
Bello Abdullahi Maimaje (25)   Link to this post
do you mean how many sorting method we have in c++?
please, explain what do you want
mbahdoekon (2)   Link to this post
yup..how many ways of sorting in c++..
Bazzy (4120)   Link to this post
Can you define what a 'way of sorting' is?
You can declare your own comparing function and sort using it if this is what you mean. This implies that C++ has an infinite amount of 'ways of sorting'
Bello Abdullahi Maimaje (25)   Link to this post
selection sort, bubble sort, insertion sort, quick sort and heap sort
Bazzy (4120)   Link to this post
Those things are to be implemented by yourself, the standard sorting functions don't have to stick to a defined algorithm. C++ standards only say the complexity that algorithm should have.
helios (6080)   Link to this post
There are only two sorting algorithms: std::sort() and std::stable_sort(). The difference is that the latter guarantees that elements of the same value will maintain their relative ordering.
For example, [2,1,2,3] will become [1,2,2,3], and never [1,2,2,3].
Both algorithms have a guaranteed best-case complexity of O(n log n). std::sort() has no guaranteed worst-case complexity, but it will never be above O(n2). std::stable_sort() has a guaranteed worst-case complexity of O(n log2 n).
Last edited on
firedraco (2625)   Link to this post
What about std::heap_sort() (or whatever it's called) or qsort (from C)?
helios (6080)   Link to this post
http://www.cplusplus.com/reference/algorithm/sort_heap/
Yeah, that's another one, but I have no idea what it does.
firedraco (2625)   Link to this post
It's a sort in place algorithm to take a heap (as an array) and turn it into a sorted array. I'm guessing it's faster than a normal sorting algorithm.

This topic is archived - New replies not allowed.