Looking for reliable answers? Westonci.ca is the ultimate Q&A platform where experts share their knowledge on various topics. Get expert answers to your questions quickly and accurately from our dedicated community of professionals. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
Answer:
c. 3
Explanation:
The line of code on line 19
elements[minIndex] = temp;
will run a total of 3 times in with this call to the selectionSort method. The first time it will turn the 10 in position 2 into a 30. The second time it will turn the 20 in position 4 into a 40. Finally, it will turn the newly positioned 40 in position 4 into a 50. Therefore, completely sorting the array's elements.
The statement elements[minIndex] = temp; in line 19 of the method is executed 3 times as a result of the call to selectionSort
The array is declared as:
int[] arr = {30, 40, 10, 50, 20};
To sort the above array, the selectionSort algorithm would
- swap the positions of 10 and 30
- swap the positions of 20 and 40
- swap the positions of 50 and the new position of 40
Hence, the selectionSort algorithm would execute line 19 3 times
Read more about algorithms at:
https://brainly.com/question/15263760
Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Westonci.ca is here to provide the answers you seek. Return often for more expert solutions.