Selection Sort on 1 Million Elements: Is It Feasible?

  • Thread starter Thread starter rsala004
  • Start date Start date
  • Tags Tags
    Elements Sort
AI Thread Summary
Selection sort is not feasible for sorting a large array of size 1,000,000 on an everyday laptop due to its inefficiency, requiring approximately 500 billion operations to complete. Modern laptops can execute between 10 to 20 billion instructions per second, which translates to an estimated sorting time of 50 to 100 seconds for a trillion instructions. However, considering memory access times, this could extend to around 1,000 seconds. It is recommended to use more efficient sorting algorithms, such as quicksort, available in standard libraries, rather than relying on selection sort for large datasets.
rsala004
Messages
23
Reaction score
0
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
 
Technology news on Phys.org
No, use your standard library sorting algo or google sorting and you will find many better ones, like quicksort, for example.
 
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:

https://www.physicsforums.com/showthread.php?t=218369
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top