+ 4

# What is the best sorting algorithm ?

There are so many sorting algorithms . I want to know which one is the best . And what algorithm is applied in build-in sort function of various IDEs ,like codeblocks. ??

4 Answers

+ 4

It depends what you're sorting, and what is known about the data you're sorting. What assumptions can be made about the data, in order to optimise a particular search algorithm.
Also note, there's luck involved. A bad sorting algorithm will sometimes be better than a better one, if it gets lucky. If you measure efficiency on a single list, then that list might be brilliant for bubble sort, but not good for an insertion sort. How do you measure how good a sort algorithm is? What datasets would you use?

+ 3

No true dataset is random. If you are sorting ISBN numbers, then you know something about the data.

0

what if it is a random data set ? what if i have to pick an algorithm without knowing the type of the data set , what would apparently work better for all cases ?

- 3

C++