Click here to Skip to main content
14,427,818 members
Rate this:
Please Sign up or sign in to vote.
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?
Posted
Comments
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.
Rate this:
Please Sign up or sign in to vote.

Solution 1

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).
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

If only CodeProject had one of the best articles on the subject[^].
   
Rate this:
Please Sign up or sign in to vote.

Solution 3

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.
   
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 5,178
Richard MacCutchan 1,899
phil.o 1,270
Patrice T 1,217
MadMyche 1,175



CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100