Study Guides (248,617)
CS 246 (16)
Ric Holt (3)
Final

# Final review - Winter 2009 useful questions to practice on

6 Pages
175 Views

Department
Computer Science
Course Code
CS 246
Professor
Ric Holt

This preview shows pages 1 and half of page 2. Sign up to view the full 6 pages of the document.
Description
CS 246 Final Review Sean Hsueh 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 class interface? 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: class T f private: // some junk.. public: T (); // some other junk... g; 1 class queue f public: queue (); void enqueue ( T▯ t ); T▯ dequeue (); bool isEmpty (); g; 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. #include #include using namespace std; struct Node f string val; Node▯ next; g; void rprint ( Node▯ n ); 9. Why is it necessary to explicitly put extern on variables in headers, but not functions? 2 10. Given the following template function, what operations must type T provide? #include using namespace std; template < typename T > T geeseOnCampus ( T& a, T& b ) f T c = a + 3; cout << c << endl; if ( c == b ) return c.increment (); else return c / b; g 11. What does the following template do? What happens when the program is run? #include using namespace std ; template < int N > struct Temp f const static int A = N ▯ Temp < N ▯ 1 > : :A; const static int B = N + Temp < N ▯ 1 > : :B; g; template <> struct Temp < 0 > f const static int A = 1; const static int
More Less

Only pages 1 and half of page 2 are available for preview. Some parts have been intentionally blurred.

Unlock Document

Unlock to view full version

Unlock Document
Me

OR

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Join to view

OR

By registering, I agree to the Terms and Privacy Policies
Just a few more details

So we can recommend you notes for your school.