Which sorting algorithm does the STL sort uses to sort elements? Is it always the same or different for different sets of data. asked 02 Feb '16, 20:26

There are three methods under Sorting Algorithms for STL,following are : a> sort. b> is_sorted. c> partial_sort. you need to implement them according to the data given : implementation methods for these three sorting algorithms are : a> This function of the STL, sorts the contents of the given range. There are two version of sort() : sort(start_iterator, end_iterator ) : sorts the range defined by iterators start_iterator and end_iterator in ascending order. sort(start_iterator, end_iterator, compare_function) : this also sorts the given range but you can define how the sorting should be done by compare_function. b> partial_sort() sorts first half elements in the given range, the other half elements remain as they was initially. partial_sort() also has two variations: partial_sort(start, middle, end ) : sorts the range from start to end in such a way that the elements before middle are in ascending order and are the smallest elements in the range. partial_sort(start, middle, end, compare_function) : sorts the range from start to end in such a way that the elements before middle are sorted with the help of compare_function and are the smallest elements in the range. c> This function of the STL, returns true if the given range is sorted. There are two version of is_sorted() : is_sorted(start_iterator, end_iterator) : Checks the range defined by iterators start_iterator and end_iterator in ascending order. is_sorted(start_iterator, end_iterator, compare_function) : It also checks the given range but you can define how the sorting must be done. Hope it cleared out your query. answered 04 Feb '16, 04:18

Go through this : http://stackoverflow.com/questions/1717773/whichsortingalgorithmisusedbystlslistsort answered 02 Feb '16, 20:34

You can find detailed explanation here . answered 02 Feb '16, 21:44

It uses Introsort which is a combination on heap sort and quick sort.Worst case complexity is O(NlogN) Actually if you are looking for a standard there's no requirement for a particular algorithm but it has to be stable. So , one might say it is implementation defined. answered 02 Feb '16, 22:23

It uses Introsort which is a combination on heap sort and quick sort.Worst case complexity is O(NlogN) Actually if you are looking for a standard there's no requirement for a particular algorithm but it has to be stable and must has a complexity O(nlogn). So , one might say it is implementation defined. answered 02 Feb '16, 22:23

it uses intro sort,a combination of quick and heap sort. you can also use "qsort". check this function here for more details http://www.cplusplus.com/reference/cstdlib/qsort/ answered 04 Feb '16, 13:26
