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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 03:50, nakeytrag
Iam a bacterium. i cause stomach cramps and diarrhea. i am caused by eating rotten foodssuch as chicken, fish, or eggs. sometimes turtles carry my bacteria. what am i?
Answers: 2
image
Computers and Technology, 24.06.2019 12:50, opgbadwolf5
When is it most apprpriate for a development team to change the definition of done
Answers: 1
image
Computers and Technology, 24.06.2019 17:30, leenzazou98241
What is the next step if your volume does not work on computer
Answers: 2
image
Computers and Technology, 25.06.2019 08:00, destineenikole175
Implement a document scanning function wordcountengine, which receives a string document and returns a list of all unique words in it and their number of occurrences, sorted by the number of occurrences in a descending order. if two or more words have the same count, they should be sorted according to their order in the original sentence. assume that all letters are in english alphabet. you function should be case-insensitive, so for instance, the words “perfect” and “perfect” should be considered the same word.
Answers: 1
You know the right answer?
Consider the following correct implementation of the selection sort algorithm. public static void s...

Questions in other subjects: