Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Evening

I have a vector of int that I need to sort in ascending order and I am looking for the most optimized algorithm to do it.
For my case I guess quicksort is the most recommended one, but anyway I would like to check if that's right.

I have 6 cases that I want to test:
* 10 milion elements array generated randomly
* 100 milion elements array generated randomly
* 10 milion elements array already sorted
* 100 milion elements array already sorted
* 10 milion elements array sorted in descending order
* 100 milion elements array sorted in descending order

I saw people recommending to use some algorithm until I reach certain point e then use another for improving optimization.
For my case should I change the algorithm depending on the array size or it isn't necessary? Is there any other way that can improve those tests?
Philippe Mori 1-Oct-15 23:09pm    
Why not try it? By the way, if predefined algorithm is enough, just use it. As long as the algorithm is O(n log n), you should have adequat performance in you case.

Looks like home work to me.

Why not add time measure to your code, implement different algorithms and measure the outcome for the different cases.
That should give you the answer which method is most efficient for each case (or maybe for all).
Share this answer
If only CodeProject had one of the best articles on the subject[^].
Share this answer
You know the major sorting algorithms have been studied and their performance is known (I would reccomend the oldie-goldie Wirth's book[^] as starting point).

If you are really curious to measure the performance on your set of data then no one prevents you in doing that.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900