Question 14958 – DSSSB TGT 2017
February 20, 2024Question 11772 – Sorting
February 20, 2024GATE 2006
Question 14
|
Which one of the following in place sorting algorithms needs the minimum number of swaps?
Quick sort
|
|
Insertion sort
|
|
Selection sort
|
|
Heap sort
|
Question 14 Explanation:
Selection sort requires minimum number of swaps i.e O(n). The algorithm finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list. It does no more than n swaps, and thus is useful where swapping is very expensive.
Correct Answer: C
Question 14 Explanation:
Selection sort requires minimum number of swaps i.e O(n). The algorithm finds the minimum value, swaps it with the value in the first position, and repeats these steps for the remainder of the list. It does no more than n swaps, and thus is useful where swapping is very expensive.