10 votes 10 votes Which one of the following in-place sorting algorithms needs the minimum number of swaps? Insertion Sort Quick Sort Heap Sort Selection Sort Algorithms isro2017 algorithms sorting + – sh!va asked May 7, 2017 sh!va 4.8k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
Best answer 9 votes 9 votes Selection Sort is best sorting algorithm in terms of minimum no. of swap = O(n) pawan kumarln answered May 8, 2017 selected May 8, 2017 by Samujjal Das pawan kumarln comment Share Follow See all 4 Comments See all 4 4 Comments reply Aman Bisht commented Jun 13, 2017 reply Follow Share complexity of selection sort is n^2, then why it has minimum number of swaps...but complexity of Heap sort is nlogn...then why it doesn't have minimum number of swaps.. 0 votes 0 votes Sushant Yadav 1 commented Jul 1, 2017 i edited by Sushant Yadav 1 Dec 18, 2017 reply Follow Share Becoz in selection sort in each iteration only one element which is smallest or largest according to implementation is putted in to its exact position which counts for one swap ..same procedure happens for other n-1 elements so no. Of swaps O(n)... But in case of heap each element may take up logn swaps in worst case .. so for n elements swaps would be O(nlogn).. 4 votes 4 votes Yogeshwar Misal 6 commented Aug 2, 2017 reply Follow Share @aman Don't confuse youself between #comparisons and #swaps 2 votes 2 votes princeit07 commented Jun 26, 2021 reply Follow Share “Are we taking Selection Sort as a minimum no. of swaps considering for both best and worst-case ??” “As we all know that insertion sort has minimum no. of swaps comparatively from Selection sort if the given list is already sorted.” 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Selection sort vinaykumar700156 answered May 7, 2017 vinaykumar700156 comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes option (d)....O(n) joshi_nitish answered May 7, 2017 joshi_nitish comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes In insertion sort there is no swapping....so 0 swapping in insertion sort...so i think answer should be insertion sort. debanjan sarkar answered Oct 4, 2017 debanjan sarkar comment Share Follow See 1 comment See all 1 1 comment reply Nit9 commented Oct 31, 2017 reply Follow Share Thats just in presorted list as input, not in all cases, worst will in n(n-1)/2 swaps in case of reverse sorted list Where in slection sort in all input cases, only n swaps are required 0 votes 0 votes Please log in or register to add a comment.