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) |
||||
|
|
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) |
||||
|
|
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:
|
|
for (int x
: numbers) |
|||
|
for (int
numbers : x) |
||||
|
for (List x : numbers) |
||||
|
for (List numbers : 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 |
||||
|
|
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 |
|
|
|
d |
Comments
Post a Comment