wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Practice for AP Java Quiz #13 Sorting

Total questions: 20

Worksheet time: 12mins

Name
Class
Date
1.
Which sorting algorithm makes one swap per pass (possibly swapping an element with itself)?
a)
Selection Sort
b)
Bubble Sort
c)
Insertion Sort
2.
Which sorting algorithm may make multiple swaps per pass?
a)
Bubble Sort
b)
Selection Sort
c)
Insertion Sort
3.
Which sorting algorithm shifts elements instead of swapping elements if needed in each pass.
a)
Bubble Sort
b)
Selection Sort
c)
Insertion Sort
4.
The following lists represent 3 passes of a sorting algorithm. Which algorithm is being used to sort the list?
 
4    5    9    6    2    7

4    5    6    2    7    9 
4    5    2    6    7    9
a)
Bubble Sort
b)
Selection Sort
c)
Insertion Sort
5.
The following lists represent 3 passes of a sorting algorithm. Which algorithm is being used to sort the list?
 
4    8    6    2    5    7 
4    8    6    2    5    7 
4    6    8    2    5    7
a)
Bubble Sort
b)
Selection Sort
c)
Insertion Sort
6.
The following lists represent 3 passes of a sorting algorithm. Which algorithm is being used to sort the list?
 
4    8    3    9    2    6 
2    8    3    9    4    6
2    3    8    9    4    6
a)
Bubble Sort
b)
Selection Sort
c)
Insertion Sort
7.
We are sorting the following list in ascending order:
 
1    4    2    9    3    8    5
 
What does the list look like after one pass of the bubble sort algorithm. 
a)
1 2 4 3 8 5 9
b)
1 4 2 5 3 8 9
c)
4 2 9 3 8 5 1
8.
We are sorting the following list in descending order:
 
1    4    2    9    3    8    5
 
What does the list look like after one pass of the selection sort algorithm.
a)
1 4 2 9 3 8 5
b)
9 4 2 1 3 8 5
c)
4 2 9 3 8 5 1
9.
We are sorting the following list in ascending order:
 
1    4    2    9    3    8    5
 
What does the list look like after one pass of the insertion sort algorithm. 
a)
1 4 2 9 3 8 5
b)
4 2 9 3 8 5 1
c)
4 1 2 9 3 8 5
10.
A binary search algorithm will only work on a list which is in order. True or False
a)
True
b)
False
11.
Using a binary search why will the number 9 never be found in the following list:
11, 8, 13, 9, 7, 3
a)
It does not work on numbers
b)
It only works on letters
c)
The list is not in order
12.

What algorithm does this image represent?

a)

Bubble sort

b)

Merge sort

c)

Linear search

d)

Binary search

13.

Which of these algorithms eliminates half of its possibilities each time it makes a check?

a)

Binary search

b)

Bubble sort

c)

Merge sort

d)

Linear search

14.

How many elements of the array {4,7,9,11,20,24,30,41} would be visited in a binary search for 27?

a)

2

b)

3

c)

4

d)

5

15.

What is the output of this program?

a)

Not found

b)

Found

c)

12

d)

ArrayIndexOutOfBoundsException

16.

Which of the following is the best replacement for <missing code>?

a)

guess == wrong

b)

low == high

c)

low > high

d)

low < high

17.

Which sorting algorithm is illustrated in this animation?

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

d)

Merge Sort

18.

Which name best matches this code?

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

d)

Merge

19.

2 robots race to find a name in a sorted list. Robot A uses a binary search and Robot B uses linear. Who will win?

a)

Robot A will always win

b)

Robot B will always win

c)

Robot A will probably, but not always, win

d)

Robot B will probably, but not always, win

20.

Which name best matches this code?

a)

Bubble Sort

b)

Selection Sort

c)

Insertion Sort

d)

Merge