COMPUTER SCIENCE AND ENGINEERING
ALGORITHMS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
Which sorting algorithm makes one swap per pass (possibly swapping an element with itself)?
|
Selection Sort
|
|
Bubble Sort
|
|
Insertion Sort
|
|
None of the above
|
Explanation:
Detailed explanation-1: -This algorithm is called selection sort because it repeatedly selects the next-smallest element and swaps it into place.
Detailed explanation-2: -ANSWER: Selection sort Hence, we say that selection sort takes the minimum number of swaps.
Detailed explanation-3: -Which sorting algorithms may make multiple swaps per pass? Bubble sort may make multiple swaps in a single pass.
Detailed explanation-4: -The selection sort improves on the bubble sort by making only one exchange for every pass through the list.
Detailed explanation-5: -Selection sort is the algorithm which takes minimum number of swaps, and in the best case it takes ZERO (0) swaps, when the input is in the sorted array like 1, 2, 3, 4.
There is 1 question to complete.