Question: In this exercise, we will be looking at our example code for Selection Sort. However, while we are sorting we will also count the number
In this exercise, we will be looking at our example code for Selection Sort.
However, while we are sorting we will also count the number of swaps taking place, then print them out once the array has been sorted.
Add a print statement at the end of the selectionSort method that prints out the number of swaps that took place during the sort.
You should not modify the main method.
Hint: Where are items compared? Try writing out the steps in the algorithm on paper to help.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
