Sort Search BigO Iterator M/C Test

By Mickey Arnold
Last updated 10 months ago
40 Questions

Which of the following sorts has a partition method that uses a pivot location?

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);
}
}

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);
}
}

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);

Which of the these algorithms has a O(1) best case runtime and a O(N) worst case runtime?

Which of the these algorithms has a O(N) best case runtime and a O(N*N) worst case runtime?

Which of the these algorithms has a O(N*Log2N) best case runtime and a O(N*N) worst case runtime?

Which of the following sorts selects an item and then moves items around to put the selected item in the correct location?

Which of these is the correct BigO for searching a single linked linked-list?

Which of the these algorithms has a O(N*N) best case runtime and a O(N*N) worst case runtime?

Which of the these algorithms has a O(1) best case runtime and a O(Log2N) worst case runtime?

Which of these is the correct BigO for adding an item to the front of an array?

Which of these is the correct BigO for adding an item to the end of an array?

Which of these is the correct BigO for adding an item to the front of a Java LinkedList?

Which of these is the correct BigO for deleting any item from an ArrayList?

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;
}
}
}

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;
}
}
}