The number of swaps performed by selection sort is _______ in the worst-case scenario.

  • O(1)
  • O(log n)
  • O(n)
  • O(n^2)
In the worst-case scenario, the number of swaps performed by selection sort is O(n^2). This is because, in each iteration, the algorithm selects the minimum element and swaps it with the element at the beginning, contributing to a quadratic number of swaps for a sorted array.
Add your answer
Loading...

Leave a comment

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