PA of Algorithms Q60

0. What is the number of swaps required to sort n elements using selection sort, in the worst case?

  • Option : A
  • Explanation :
    If there are n elements, then in worst case, total swaps will be (n-1) in selection sort. So the number of swaps is Θ(n).
    Alternately
    The selection sort is similar to bubble sort except it does not swap elements with every move. The sorting algorithm first finds the smallest element in the list and then puts it in to place in single swap. So n swap required for n elements.
Cancel reply

Your email address will not be published. Required fields are marked *


Cancel reply

Your email address will not be published. Required fields are marked *