answersLogoWhite

0

Selection sort works by looking for the largest value in a set and swapping it with the last value. The last value can now be ignored since it is now in place. The process repeats with the remainder of the set. After repeated passes, the remainder of the set will have only one item, the smallest value, at which point all the values will be in sorted order.

The algorithm is similar to that of bubblesort, but is generally more efficient because there can only be one swap at most for each iteration of the algorithm. With bubble sort, there may be multiple swaps per iteration. However, while the number of comparisons is the same for both algorithms, bubblesort can be optimised to minimise the number of iterations required and thus minimise the number of comparisons. Nevertheless, swapping is a more expensive operation than comparing, thus selection sort is generally faster.

Neither algorithm is suitable for sorting large sets of data.

User Avatar

Wiki User

9y ago

What else can I help you with?

Continue Learning about Engineering

When is quick sort better than selection sort?

Because the quick sort can be used for large lists but selection not. selection sort is used to find the minimum element ,but quick choose element called pivot and move all smaller nums before it & larger after it.


Is selection sort and tournament sort are same?

No. Tournament sort is a variation of heapsort but is based upon a naive selection sort. Selection sort takes O(n) time to find the largest element and requires n passes, and thus has an average complexity of O(n*n). Tournament sort takes O(n) time to build a priority queue and thus reduces the search time to O(log n) for each selection, and therefore has an average complexity of O(n log n), the same as heapsort.


How do you implement selection sort in c with graphics?

Selection sort has the following implementation: // sort an array if integers of length size in ascending order using selection sort algorithm: void selection_sort (int a[], unsigned size) { unsigned i, max; while (size > 1) { max = 0; for (i=1; i!=size; ++i) if (a[i] > a[max]) max = i; swap (a[max], a[--size]); } }


What are the applications of selection sort?

None. Selection sort can only be used on small sets of unsorted data and although it generally performs better than bubble sort, it is unstable and is less efficient than insert sort. This is primarily because insert sort only needs to scan as far back as required to perform an insertion whereas selection sort must scan the entire set to find the lowest value in the set. And although selection sort generally performs fewer writes than insert sort, it cannot perform fewer writes than cycle sort, which is important in applications where write speed greatly exceeds read speed.


How many passes will Selection sort make?

n-1

Related Questions

Which sorting algorithm is more efficient for large datasets: quick sort or selection sort?

Quick sort is more efficient for large datasets compared to selection sort.


Which sorting algorithm is more efficient for small datasets: bubble sort or selection sort?

Selection sort is more efficient for small datasets compared to bubble sort.


What is the best data structure for heap sort?

selection sort


What is the operation of a selection sort?

You sort a selected range of cells.


What are the advantages and disadvantages of selection sort?

No


When is quick sort better than selection sort?

Because the quick sort can be used for large lists but selection not. selection sort is used to find the minimum element ,but quick choose element called pivot and move all smaller nums before it & larger after it.


When is it more appropriate to use insertion sort than selection sort?

It is more appropriate to use insertion sort when the list is nearly sorted or has only a few elements out of place. Insertion sort is more efficient in these cases compared to selection sort.


What is the Big O notation of the selection sort algorithm?

The Big O notation of the selection sort algorithm is O(n2), indicating that its time complexity is quadratic.


Is selection sort and tournament sort are same?

No. Tournament sort is a variation of heapsort but is based upon a naive selection sort. Selection sort takes O(n) time to find the largest element and requires n passes, and thus has an average complexity of O(n*n). Tournament sort takes O(n) time to build a priority queue and thus reduces the search time to O(log n) for each selection, and therefore has an average complexity of O(n log n), the same as heapsort.


How do you implement selection sort in c with graphics?

Selection sort has the following implementation: // sort an array if integers of length size in ascending order using selection sort algorithm: void selection_sort (int a[], unsigned size) { unsigned i, max; while (size > 1) { max = 0; for (i=1; i!=size; ++i) if (a[i] > a[max]) max = i; swap (a[max], a[--size]); } }


What are the applications of selection sort?

None. Selection sort can only be used on small sets of unsorted data and although it generally performs better than bubble sort, it is unstable and is less efficient than insert sort. This is primarily because insert sort only needs to scan as far back as required to perform an insertion whereas selection sort must scan the entire set to find the lowest value in the set. And although selection sort generally performs fewer writes than insert sort, it cannot perform fewer writes than cycle sort, which is important in applications where write speed greatly exceeds read speed.


How many passes will Selection sort make?

n-1