Selection Sort on 1 Million Elements: Is It Feasible?

In summary, selection sort would not be feasible on an everyday laptop computer, as it would require a large number of loops to complete the sort. It would be more efficient to use a standard library sorting algorithm, such as quicksort, which would take much less time to execute. According to estimates, it would take about 100 seconds per instruction in the selective sort loop on a modern laptop. Other sorting algorithms may be more efficient and there are various source code examples available for reference.
  • #1
rsala004
23
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
  • #2
No, use your standard library sorting algo or google sorting and you will find many better ones, like quicksort, for example.
 
  • #3
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
 

Related to Selection Sort on 1 Million Elements: Is It Feasible?

What is Selection Sort?

Selection Sort is a sorting algorithm that works by repeatedly finding the minimum element from the unsorted part of the array and placing it at the beginning. This process is repeated until the entire array is sorted.

Why is Selection Sort commonly used on 1 Million Elements?

Selection Sort is commonly used on 1 Million Elements because it has a time complexity of O(n^2), making it more efficient than other sorting algorithms such as Bubble Sort or Insertion Sort on large data sets.

Is Selection Sort feasible for sorting 1 Million Elements?

Yes, Selection Sort is feasible for sorting 1 Million Elements. While it may not be the most efficient algorithm for sorting large data sets, it can still be used effectively on 1 Million Elements.

How long does it take to execute Selection Sort on 1 Million Elements?

The time it takes to execute Selection Sort on 1 Million Elements will vary depending on the specific implementation and hardware used. However, on average, it may take several minutes to several hours.

Are there any drawbacks to using Selection Sort on 1 Million Elements?

One drawback of using Selection Sort on 1 Million Elements is its time complexity of O(n^2), which makes it less efficient than other sorting algorithms on large data sets. Additionally, Selection Sort is not a stable sorting algorithm, meaning that the relative order of equal elements may not be preserved after sorting.

Similar threads

  • Programming and Computer Science
Replies
12
Views
1K
  • Programming and Computer Science
Replies
29
Views
2K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
7
Views
3K
  • Programming and Computer Science
Replies
7
Views
1K
  • Programming and Computer Science
Replies
31
Views
2K
  • Programming and Computer Science
Replies
6
Views
2K
  • Programming and Computer Science
Replies
27
Views
2K
  • Programming and Computer Science
Replies
12
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
Back
Top