Computers and Technology
Computers and Technology, 09.01.2021 18:20, 21vdawson

The following sort method correctly sorts the integers in elements into ascending order. Line 1: public static void sort(int[] elements)
Line 2: {
Line 3: for (int j = 1; j < elements. length; j++)
Line 4: {
Line 5: int temp = elements[j];
Line 6: int possibleIndex = j;
Line 7: while (possibleIndex > 0 && temp < elements[possibleIndex - 1])
Line 8: {
Line 9: elements[possibleIndex] = elements[possibleIndex - 1];
Line 10: possibleIndex--;
Line 11: }
Line 12: elements[possibleIndex] = temp;
Line 13: }
Line 14: }
Consider the following three proposed changes to the code:

Change 1
Replace line 3 with:

Line 3: for (int j = elements. length - 2; j >= 0; j--)
Change 2
Replace line 7 with:

Line 7: while (possibleIndex > 0 && temp > elements[possibleIndex - 1])
Change 3
Replace line 7 with:

Line 7: while (possibleIndex < elements. length - 1 && temp < elements[possibleIndex + 1])
and replace lines 9-10 with:

Line 9: elements[possibleIndex] = elements[possibleIndex + 1];
Line 10: possibleIndex++;
Suppose that you wish to change the code so that it correctly sorts the integers in elements into descending order rather than ascending order. Which of the following best describes which combinations of the proposed changes would achieve this goal?

Enacting changes 1 and 2 together, or enacting change 3 by itself

ONLY enacting change 2 by itself

Enacting any of the three changes individually

ONLY enacting changes 1 and 2 together

Enacting changes 1 and 3 together, or enacting change 2 by itself

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 22:50, prettybaby406
Explain why it is reasonable to assume that receiving 3 duplicate acks in tcp is an indication that the network is not currently congested.
Answers: 1
image
Computers and Technology, 22.06.2019 23:30, elizabethburkha
Which text format is this, "the text is transcribed exactly as it sounds and includes all the utterances of the speakers. "?
Answers: 2
image
Computers and Technology, 23.06.2019 15:20, headshotplayzcod
In a game with three frames, where will the objects on layer 1 appear? a. next to the play area b. in the middle of the game c. behind everything else d. in front of everything else
Answers: 1
image
Computers and Technology, 23.06.2019 22:00, bb1593
Jackson, who works in the finance department of a company, is holding a seminar for other employees on how to file taxes. only three employees sign up to attend the seminar. which device can he use to share his presentation with a group of three employees?
Answers: 1
Do you know the correct answer?
The following sort method correctly sorts the integers in elements into ascending order. Line 1: pu...

Questions in other subjects:

Konu
Mathematics, 29.09.2020 14:01
Konu
Mathematics, 29.09.2020 14:01
Konu
Mathematics, 29.09.2020 14:01
Konu
Mathematics, 29.09.2020 14:01