CS307 Spring 2010 Midterm 1 Solution and Grading Criteria. Grading acronyms: AIOBE - Array Index out of Bounds Exception may occur BOD - Benefit of the Doubt. Not certain code works, but, can't prove otherwise Gacky or Gack - Code very hard to understand even though it works or solution is not elegant. (Generally no points off for this.) GCE - Gross Conceptual Error. Did not answer the question asked or showed fundamental misunderstanding LE - Logic error in code. NAP - No answer provided. No answer given on test NN - Not necessary. Code is unneeded. Generally no points off NPE - Null Pointer Exception may occur OBOE - Off by one error. Calculation is off by one. 1.A You should comment all your code and programs, even the ones you only intend for your own use. The reason to do this is 6 months after you write a program you will forget how it works or what you were trying to do and it is more time consuming to change or update. (Because you have to figure out what the heck you code dies.) OR words to that affect. Partial credit possible B. Making a project open source is selfish because programmers will work on it and you don't have to pay them. You can incorporate their good changes into the project for free. Allen also related that when they went open source a lot more bugs in the code were found and reported so they could be fixed. OR word to that affect. Partial credit possible C. 12 D. laeyyy E. 39 F. O(N) G. O(N^2) H. O(N^2) I. O(NlogN) // base 2 okay J. O(N^2) K. O(N^2) L. 63 seconds M. 840 / 19 seconds OR 10 * 4 * 21 / 19 seconds OR 40 * 21 / 19 seconds OR a little more than 44 seconds. (40 seconds is not correct.) N. 12,500 pieces of data or 50,000 / 4 O. Sort the data. Without sorting the work is 50,000 * 1,000,000 / 2 (assume on average we look at half the elements. = 25,000,000,000 operations.

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