Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

1)

Insertion sort

2)

Heap sort

3)

Merge sort

4)

Quick sort

5)

Selection sort

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:

1)

I only

2)

II only

3)

III only

4)

I and II only

5)

II and III only

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:

1)

8 16

2)

8 16 14 28

3)

8 6 12 10 20 40

4)

8 6 12 24

5)

8 10 8 20 18 36

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:

1)

2 4 4 4 5 4 2 1

2)

2 4 3 4 4 5 4 2 1

3)

2 4 4 3 4 4 5 4 2 1

4)

2 4 3 4 4 5 4 3 2 1

5)

2 4 3 3 4 4 5 4 3 2 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Methods of Delivery Guidelines for

Answered: 1 week ago