PDA

View Full Version : selection sort?


rsala004
Oct30-09, 01:05 AM
if you have an array with size 1000000, would selection sort be feasible on a everyday laptop computer, or just too large?

I imagine it would take (1Million)2/2 loops to complete the sort

tnutty
Oct30-09, 08:27 PM
No, use your standard library sorting algo or google sorting and you will find many better ones, like quicksort, for example.

Jeff Reid
Oct31-09, 02:33 AM
I think what's he's asking is how long would it take to execute a small loop 1 trillion times on a modern lap top.

From wiki

http://en.wikipedia.org/wiki/Instructions_per_second

Probably between 10 and 20 billion instructions per second, so 50 to 100 seconds per trillion instructions, assuming the condiitions mentioned in the wiki article. So ballpark about 100 seconds per instruction in that selective sort loop. This is a crude estimate, it could be 1000 seconds per trillion instructions when you take memory accesses into account.

Here's a link to a prior thread about sorting which includes some links to source code of various sort programs:

http://www.physicsforums.com/showthread.php?t=218369