View Assessment Result: Multiple Choice Quiz 9



Your performance was as follows:

1.

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

    A.push_back( x );

is to



(a) append x to A, without checking the size and capacity of A
(b) append x to A if there is room, and otherwise overwrites the currently last element of A
(c) append x to A if and only if the size of A is less than capacity of A
(d) check whether the capacity of A is larger than the size of A, enlarges A if necessary, and append x to A

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



2.

Consider the following program segment.

vector<int>  A(10);
A.resize(0);
A.push_back(5000);

At the end of an execution of this fragment, the size of vector A is



(a) 10
(b) 1
(c) 5000
(d) 0

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, where L is a linked list of integers.

      for( it = L.begin(); it != L.end(); ++it )
        *it += 10;

Execution of this fragment has the effect of



(a) appending 10 to the list
(b) adding 10 to each list element
(c) stepping through the lists in increments of 10
(d) inserting a new element 10 after each list element

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) Nothing
(b) It does not compile.
(c) Compiles and executes, is about as fast as L.sort(), but uses much more memory.
(d) Compiles and executes, but is much slower than L.sort().

Correct answer is (b)

Your score on this question is: 0.00

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



5.
Each of the following indicates a reasonable way to implement graphs EXCEPT

(a) a binary search tree
(b) an adjacency list structure
(c) a Boolean matrix
(d) an edge list

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



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 indegrees?

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

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



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 log n)
(b) O(n^2)
(c) O(n + e)
(d) O(n * e)

Correct answer is (b)

Your score on this question is: 0.00

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



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

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

Correct answer is (b)

Your score on this question is: 0.00

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



9.
If A is an adjacency matrix for a graph G, then the matrix product A * A represents all pairs of vertices (u,v) such that

(a) there is a vertex x such that (u,x) and (v,x) are edges of G
(b) there is a vertex x such that (u,x) and (x,v) are edges of G
(c) u and v are not connected by an edge
(d) u and v are connected by two edges

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



10.
The time to compute the reverse graph for an adjacency list 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 * e)
(b) O(n)
(c) O(n + e)
(d) O(n^2)

Correct answer is (c)

Your score on this question is: 0.00

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



Go to top of assessment.

Total score: 60.00