View Assessment Result: Multiple Choice Quiz 9



Your performance was as follows:

1.
The capacity of an STL vector is defined to be the

(a) difference between the current number of elements and the maximum number of elements
(b) maximum number of elements that can be stored in the vector without resizing
(c) number of elements currently stored in the vector
(d) maximum number of elements the vector could possibly have on the given machine

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.2.1 of the course notes.
   (b) No Feedback



2.

If A is an STL vector, then the effect of executing the statement

      A[i] = x;

is to



(a) check array bounds, enlarge the vector if necessary, and then write x to position i
(b) write x to position i of the vector, without bounds checking
(c) create an iterator x pointing to position i in the array
(d) check array bounds, and write x to position i if and only if i is in the proper range

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.2.1 of the course notes.
   (b) No Feedback



3.

Consider the following code fragment concerning the STL list class.

      list<int>   L(10);
      L[3] = 555;

The fragment will produce a compile time error because



(a) the class list does not support a constructor with given length
(b) the class list does not support the bracket operator
(c) the class list only supports the const version of the bracket operator
(d) L is an array of 10 list objects, and we cannot assign 555 to a list object

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.2.1 of the course notes.
   (b) No Feedback



4.

What, if anything, is wrong with the statement

      sort( L.begin(), L.end() );

where L is a linked list?



(a) Compiles and executes, but is much slower than L.sort().
(b) Nothing
(c) Compiles and executes, is about as fast as L.sort(), but uses much more memory.
(d) It does not compile.

Correct answer is (d)

Your score on this question is: 10.00

Feedback:
   See section 2.2.1 of the course notes.
   (d) No Feedback



5.

Assume that L is an STL list object. Consider the following statement.

      while( L.size() > 0 ) { ... }

Which of the following most accurately describes what is wrong with that statement?



(a) The size() function takes time linear in the length of the list, so this is potentially very inefficient.
(b) The loop never terminates since size() always returns a positive value.
(c) Does not compile, since size() is not a member function of class list.
(d) size() requires an argument.

Correct answer is (a)

Your score on this question is: 0.00

Feedback:
   See section 2.2.1 of the course notes.
   (b) No Feedback



6.
For an adjacency list implementation of a graph with n vertices and e edges, what is the order of the time required to calculate all the outdegrees?

(a) O(n^3)
(b) O(n + e)
(c) O(n * e)
(d) O(n^2)

Correct answer is (b)

Your score on this question is: 0.00

Feedback:
   See section 2.2.1 of the course notes.
   (d) No Feedback



7.
The time to convert an adjacency list implementation of a graph with n vertices and e edges to an adjacency matrix implementation has what order?

(a) O(n^2)
(b) O(n log n)
(c) O(n + e)
(d) O(n * e)

Correct answer is (a)

Your score on this question is: 10.00

Feedback:
   See section 2.2.1 of the course notes.
   (a) No Feedback



8.
The definition of the product of two Boolean matrices is the same as the usual product of matrices except that

(a) addition is interpreted as logical-or, and multiplication is interpreted as logical-and
(b) addition is interpreted as logical-and, and multiplication is interpreted as logical-or
(c) false is interpreted as 0, true is interpreted as 1, and then ordinary matrix multiplication is used
(d) addition is interpreted as logical-and, and multiplication is interpreted as logical-xor

Correct answer is (a)

Your score on this question is: 0.00

Feedback:
   See section 2.2.1 of the course notes.
   (c) No Feedback



9.
The time to compute the reverse graph for an adjacency matrix implementation of a graph with n vertices and e edges has what order? (The reverse graph has the same vertices but all the edges are reversed.)

(a) O(n^2)
(b) O(n)
(c) O(n + e)
(d) O(n * e)

Correct answer is (a)

Your score on this question is: 0.00

Feedback:
   See section 2.2.1 of the course notes.
   (c) No Feedback



10.
The time to perform depth first search, starting at the first vertex of a graph with n vertices and e edges implemented as an adjacency list has what order?

(a) O(n * e)
(b) O(n + e)
(c) O(n)
(d) O(n^2)

Correct answer is (b)

Your score on this question is: 10.00

Feedback:
   See section 2.2.1 of the course notes.
   (b) No Feedback



Go to top of assessment.

Total score: 60.00