Question
Saved Which of the following sorting algorithms is described by this text? Take the item at index 1 and see if it is in order
Saved
Which of the following sorting algorithms is described by this text? "Take the item at index 1 and see if it is in order compared to the item at index 0. If it is not, then swap the two items. Next take the item at index 2 and compare it to the items at the lower indexes. Move items in the lower indexes to a higher one until you find the proper location to place the value so that it is in the correct order. Continue this process with all remaining indexes." (2 points)
Question 12 options:
|
| ||
|
| ||
|
| ||
|
| ||
|
|
Question 13 (6 points)
Saved
Which of the following sorting algorithms is NOT written recursively? (1 point)
I. selection sort II. insertion sort III. merge sort
Question 13 options:
|
| ||
|
| ||
|
| ||
|
| ||
|
|
Question 14 (12 points)
Saved
What is output by this code segment? (2 points)
int i = 8;
while(i <= 25) { System.out.print(i + " "); if((i % 3) == 0) { i *= 2; } else { i -= 2; } }
Question 14 options:
|
| ||
|
| ||
|
| ||
|
| ||
|
|
Question 15 (12 points)
Saved
The following method is intended to remove all values from the ArrayList < Integer > aList that have the same value as val; however, this method does NOT work correctly.
public void removeValue(ArrayList < Integer > aList, int val) { int i;
for(i = 0; i < aList.size(); i++) { if(aList.get(i) == val) { aList.remove(i); } } }
If aList initially contains 2 3 4 3 3 4 4 5 4 3 2 1 and val is equal to 3, then aListshould contain 2 4 4 4 5 4 2 1 after removeValue is invoked. What does aListactually contain after removeValue is invoked? (2 points)
Question 15 options:
|
| ||
|
| ||
|
| ||
|
| ||
|
|
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started