subject

Consider the following correct implementation of the selection sort algorithm. public static void selectionSort(int[] elements)

{
for (int j = 0; j < elements. length - 1; j++)
{
int minIndex = j;
for (int k = j + 1; k < elements. length; k++)
{
if (elements[k] < elements[minIndex])
{
minIndex = k;
}
}
if (j != minIndex)
{
int temp = elements[j];
elements[j] = elements[minIndex];
elements[minIndex] = temp; // line 19
}
}
}
The following declaration and method call appear in a method in the same class as selectionSort.

int[] arr = {30, 40, 10, 50, 20};
selectionSort(arr);

How many times is the statement elements[minIndex] = temp; in line 19 of the method executed as a result of the call to selectionSort ?

a. 1
b. 2
c. 3
d. 4
e. 5

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen too
Answers: 2
question
Computers and Technology, 23.06.2019 02:00
Which software would you use to create a print design? a. illustrator b. audacity c. reaper d. dreamweaver
Answers: 2
question
Computers and Technology, 23.06.2019 17:00
What are the 12 colors of the spectrum called?
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
You know the right answer?
Consider the following correct implementation of the selection sort algorithm. public static void s...
Questions
question
English, 10.12.2019 05:31