{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm 2 Solutions 13


Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tic). The heaviest deductions were for slow solutions (using an ArrayList instead of a HashSet, or doing nested iterations and not saving the names at all). These slow solutions run in O(n^2) time rather than O(n), which was unacceptable. Some students also didn’t realize that the instructions to use a “hash table” meant they could use a HashSet or a HashMap. “hash table” is just a generic term that can refer to either. HashSet suited this problem better, but some students made a HashMap work and weren’t deducted for it. Question 4B: Version A: Correct Answer: Wilma, Hilary, Homer Partial Credit (Reversed Depth­First, or pushed in wrong order): Homer, Hilary, Wilma Version B: Correct Answer: Marge, Bart, you Partial Credit (Reversed Depth­First, or pushed in wrong order): You, Bart, Marge Common Mistakes: Some answers saw that we were using a stack, and assuming the order based on that... Amoebas were pushed onto the stack left to right, which causes the traversal to go down the right side of the tree first. Some students confused breadth first with other traversals, or had no clear pattern to how they traversed the tree. Putting down the same Amoeba multiple times (or naming an Amoeba we did not ask for) were considered completely wrong. Question 5: / apeslto / *Sml ouin* pbi ola aeoptto BnrTe xr ulcboensmCmuain(iayreep){ rtr epr(yot xrmRo) eunhle mRo,ep.yot; } piaeboenhle(reoero1 reoero2 rvt ola eprTeNd ot,TeNd ot){ i ro1=...
View Full Document

{[ snackBarMessage ]}