Log in
Sign up for FREE
arrow_back
Library
Sort Search BigO Iterator M/C Test
By Mickey Arnold
star
star
star
star
star
Share
share
Last updated almost 2 years ago
40 questions
Add this activity
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
Question 1
1.
Which of the following sorts has a partition method that uses a pivot location?
bubble sort
merge sort
insertion sort
selection sort
quick sort
Question 2
2.
What is the bigO of the code below?
int n = //user input
for(int i=0; i<n; i++){
for(int j=0; j<n; j++){
System.out.println(i*j);
}
}
O(N)
O(1)
O(N * log2N)
O(Log2N)
O(N*N)
Question 3
3.
What is the bigO of the code below?
int n = //user input
for(int i=0; i<n; i++){
for(int j=1; j<n; j=j*2){
System.out.println(i*j);
}
}
O(N)
O(1)
O(N * log2N)
O(Log2N)
O(N*N)
Question 4
4.
What is output by the code below?
String[] s = "one two dog".split(" ");
ArrayList<String> words;
words = new ArrayList<String>(Arrays.asList(s));
String big = Collections.min(words);
out.println(big);
one
two
dog
one two dog
one two
Question 5
5.
Which of the these algorithms has a O(1) best case runtime and a O(N) worst case runtime?
Binary Search
Linear Search
Selection Sort
Insertion Sort
Quick Sort
Question 6
6.
Which of the these algorithms has a O(N) best case runtime and a O(N*N) worst case runtime?
Binary Search
Linear Search
Selection Sort
Insertion Sort
Quick Sort
Question 7
7.
Which of the these algorithms has a O(N*Log2N) best case runtime and a O(N*N) worst case runtime?
Binary Search
Linear Search
Selection Sort
Insertion Sort
Quick Sort
Question 8
8.
Which of the following sorts selects an item and then moves items around to put the selected item in the correct location?
merge sort
insertion sort
quick sort
selection sort
heap sort
Question 9
9.
Which of these is the correct BigO for searching a single linked linked-list?
O(N)
O(Log2N)
O(N * log2N)
O(1)
O(N2)
Question 10
10.
Which of the these algorithms has a O(N*N) best case runtime and a O(N*N) worst case runtime?
Binary Search
Linear Search
Selection Sort
Insertion Sort
Quick Sort
Question 11
11.
Which of the these algorithms has a O(1) best case runtime and a O(Log2N) worst case runtime?
Binary Search
Linear Search
Selection Sort
Insertion Sort
Quick Sort
Question 12
12.
Which of these is the correct BigO for adding an item to the front of an array?
O(N)
O(Log2N)
O(N * log2N)
O(1)
O(N*N)
Question 13
13.
Which of these is the correct BigO for adding an item to the end of an array?
O(N)
O(Log2N)
O(N * log2N)
O(1)
O(N*N)
Question 14
14.
Which of these is the correct BigO for adding an item to the front of a Java LinkedList?
O(N)
O(Log2N)
O(N * log2N)
O(1)
O(N*N)
Question 15
15.
Which of these is the correct BigO for deleting any item from an ArrayList?
O(N)
O(Log2N)
O(N * log2N)
O(1)
O(N*N)
Question 16
16.
Which of the following would correctly fill < blank 1 > ?
public static void sortOne( Comparable[] list )
{
for(int i=0; i<list.length-1; i++)
{
int min = i;
for(int j=i+1; j<list.length; j++)
{
if(list[j].
< blank 1 >
(list[min])<0)
min = j;
}
if( min != i)
{
Comparable temp = list[min];
list[min] = list[i];
list[i] = temp;
}
}
}
compareTo
int
Comparable
String
Object
Question 17
17.
Assuming <blank 1> is filled correctly, what sort is sortOne()?
public static void sortOne( Comparable[] list )
{
for(int i=0; i<list.length-1; i++)
{
int min = i;
for(int j=i+1; j<list.length; j++)
{
if(list[j].
< blank 1 >
(list[min])<0)
min = j;
}
if( min != i)
{
Comparable temp = list[min];
list[min] = list[i];
list[i] = temp;
}
}
}
bubble sort
selection sort
insertion sort
binary search
merge sort
Question 18
18.
A
Question 19
19.
A
Question 20
20.
A
Question 21
21.
A
Question 22
22.
A
Question 23
23.
A
Question 24
24.
A
Question 25
25.
A
Question 26
26.
A
Question 27
27.
A
Question 28
28.
A
Question 29
29.
A
Question 30
30.
A
Question 31
31.
A
Question 32
32.
A
Question 33
33.
A
Question 34
34.
A
Question 35
35.
A
Question 36
36.
A
Question 37
37.
A
Question 38
38.
A
Question 39
39.
A
Question 40
40.
A