Minimize swap

Which of the following sorting algorithm requires the minimum number of swaps?

Insertion sort Quick sort Selection sort Heap sort

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Beakal Tiliksew
Oct 31, 2015

Even though selection sort has poor performance, it requires the minimum number of swaps. It does a maximum of n n swaps, where n n is the number of elements in a list. Once an element is swapped, it will be fixed.

The poor performance of selection sort comes from the high number of comparisons made which is O ( n 2 ) O(n^{2}) .

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...