0
Which sorting algorithm is the fastest?
Ignoring memory consumption I am confused by this question, there are so many fast ones, which one to choose? For an array of numbers
3 ответов
+ 5
Some more background information for your decision:
https://stackoverflow.com/questions/773253/what-sort-algorithm-provides-the-best-worst-case-performance
I would make some assumptions about the dataset that needs to be sorted. Is it small or large?
Are you looking for best case scenario (elements are almost sorted already) or worst case (most unfavorable initial state for the specific algorithm)?
Are the numbers integers of floating point?
Based on these assumptions, you can pick your algorithm.
Maybe you can pick multiple algorithms and test their performance on the same dataset. :) That would be an interesting exercise in any case.
+ 5
I would think, you cannot generalize completely about the fastest algorithm. It may depend on many things, even if you talk about an array of numbers.
There are many different types of numbers, even among integers and floating point values, their size (number of bits) can be different, and certain CPU architectures may be more efficient working with certain types but struggle with others.
The size of the array can be significant, and also the initial state of the elements, the winning algorithm could be different if all except one element is already sorted, or the elements are in reverse order or completely random.
So in short, this question can be answered best, if you consider all these specific factors.
0
Tibor Santa thanks for the answer! That's the point - I am given a task to implement "the fastest sorting algorithm" with such conditions, but they're really too general, I don't know how to do it...