In selection sort, how many comparisons are performed in the inner loop in each iteration?

  • i
  • n
  • n - 1
  • n - i
In each iteration of the inner loop in selection sort, where 'i' is the current iteration, n - i comparisons are performed. This is because the inner loop looks for the minimum element in the unsorted portion and places it at the beginning, reducing the number of comparisons in subsequent iterations.
Add your answer
Loading...

Leave a comment

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