| CS 311 Fall 2007 > Final Exam Review Problems, Part 4 |
This is the fourth of four sets of review problems for the Final Exam. A complete review for the final includes the material of the Midterm Exam as well, which is covered in three problem sets posted earlier in the semester. For all seven sets, see the the class web page, or the following links:
Review problems are given below. Answers are in the Answers section of this document. Do not turn these in.
double arr[20];
for (int i = 0; i < 20; ++i)
arr[i] = i + 7.1;
cout << arr[3] << endl;
Why is there no const version of this operator?const std::map<int, int> m = mymap; // No problem cout << m[0] << endl; // COMPILER ERROR! m is const
to set the item’s value. The same is true for a std::deque and std::list. However, this is not the case for the STL Table implementations (std::set, std::map, etc.). Why not?*iter = value;

a, an, and, ankle, any
New:double arr[20];
std::map<int, double> arr;
An adjacency matrix is a 2-D array with both rows and columns indexed by the vertices of the graph. An entry is one if the two vertices are adjacent and zero if they are not.
An adjacency list contains, for each vertex, a list of the vertices it is adjacent to.
An adjacency matrix can answer the question “Are these two vertices adjacent?” very quickly. Adjacency lists are slower. On the other hand, with an adjacency list, we can quickly iterate through all the neighbors of a vertex. This may be slow with an adjacency matrix, especially for large sparse graphs (those with few edges). An adjacency matrix also typically requires more memory than an adjacency list.

| CS 311 Fall 2007: Final Exam Review Problems, Part 4 / Updated: 12 Dec 2007 / Glenn G. Chappell / ffggc@uaf.edu |
|