CS3401 Quiz 3

 

 

 

 

Linear time is the class of all complexity functions that are which of the following:

O(log n)

O(n log n)

Correct Response

O(n)

O(1)

Question 2

5 / 5 points

If an algorithm with an input size of n has two separate, unnested loops, the performance of the algorithm will be which of the following:

O(2)

Correct Response

O(n)

O(n2)

O(2n)

Question 3

0 / 5 points

Suppose you have a list named numbers whose type is ArrayList<Integer>. Then which of the following for-each loop will print out all of its elements on separate lines:

Correct Answer

for (int x : numbers)
    System.out.println(x);

for (int numbers : x)   
    System.out.println(x);

for (List x : numbers)  
    System.out.println(x);

for (List numbers : x)  
    System.out.println(x);

Question 4

5 / 5 points

Suppose a list named list contains ["a", "a", "b", "b", "c", "c", "d", "d"], and you issue the following command:

    list.remove("c");

Then what is returned after that by the command:

    list.get(4);

a

b

Correct Response

c

d

Question 5

5 / 5 points

Suppose a list named list contains ["a", "a", "b", "b", "c", "c", "d", "d"], and you issue the following commands:

    list.remove(0);

    list.remove(2);

Then what is returned after that by the command:

    list.get(4);

a

b

c

Correct Response

d


 

Popular posts from this blog

CS3401 Practice Quiz 2 Part 2

CS3401 Practice Quiz 2 Part 1