Sorting algorithms which needs the minimum number of swaps - Algorithms - Selection sort

Q.  From the following sorting algorithms which algorithm needs the minimum number of swaps
- Published on 16 Jun 15

a. Bubble sort
b. Quick sort
c. Merge sort
d. Selection sort

ANSWER: Selection sort
 
First find the smallest in the array and exchange it with the element in the first position, then find the second smallest element and exchange it with the element in the second position and continue in this way until the entire array is sorted. Hence, we say that selection sort takes the minimum number of swaps.
 

    Discussion

  • Rj   -Posted on 25 Aug 20
    c. Merge sort, because in merge sort the array elements are never swapped. They do have an awful lot of memory write, but since swapping doesn't happen, hence it's minimum in merge sort

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)