{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

W08_key1 - PIC 10B EXAM 1 KEY Check your TA's name Jacob...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
PIC 10B EXAM 1 January 28, 2008 KEY Check your TA's name: Jacob ________ Ryan ________ Joe ________ You have 50 minutes to complete this exam. No books, notes, or calculators are allowed. Show all work. Incomplete, illegible, or unintelligible answers may receive no credit. There are a total of 60 points on this exam. PAGE POSSIBLE POINTS SCORE 1 14 2 11 3 5 4 20 5 10 TOTAL 60
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
1 1.) [4 points] Suppose we have a class Clown . Write the single-line declaration for each function below, as it would appear in the Clown class declaration. a.) The copy constructor for the Clown class. Clown (const Clown& right); b.) The += function to add on a Clown object, as in: clown1 += clown2; Clown& operator+= (const Clown& right); 2.) [4 points] On HW1, you were presented with two algorithms for finding an optimal tour of a set of N planets: an enumerative algorithm and a greedy algorithm. Briefly describe the advantages of each method. The greedy algorithm is faster (runs in O(N 2 ) time) but it is not guaranteed to produce the optimal answer. The enumerative algorithm is very slow (runs in O(N!) time) and is guaranteed to produce the best tour. 3.) [2 points] Darth Vader wrote a program using a class DeathStar, which has dynamic arrays in its private variables. Darth wants to name the destructor for his DeathStar class: void destroy( ); Explain why this is a bad idea.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}