CS246 Study Guide - Final Guide: Linked List, Iterator, Duplicate Code
74 views6 pages
For unlimited access to Study Guides, a Grade+ subscription is required.
CS 246 Final Review
Winter 2009, Updated: April 4, 2009
1. What does UML stand for and what are the 3 ways it is used?
2. What happens when an exception is thrown and not caught?
3. STL stack has a pop back method that is a void return type. Which design pattern should you use so that the stack
returns the last element as it is popped oﬀ?
4. What advantage does a circular linked-list have over a linear linked-list?
5. What is the diﬀerence between ’is-a’ and ’has-a’ relationship? How would you determine the relationship used in the
6. Suppose T is a instance of a specialized STL type, which element of its iterator is speciﬁed by T.end ()?
7. Suppose you have a queue for type T*. Implement the following function:
private : // some junk..
// some other junk...
void enqueue ( T∗t );
bool isEmpty ();
bool inQueue ( queue& q, T∗t );
// post−condition: returns true iﬀ t points to an object in q.
// The ordering of elements in q is unchanged when function ends.
8. Write a recursive function rprint that prints a linked list backwards.
using namespace std;
string val ;
void rprint ( Node∗n );
9. Why is it necessary to explicitly put extern on variables in headers, but not functions?