CSC148H: Introduction to Computer Science
Department of Computer Science, University of Toronto
St. George Campus, Summer 2000
Question 1 [15 marks]
Part (a) [2 marks]
| Marking Scheme |
A. -1 if a student number is missing on one page |
Part (b) [6 marks]
| Solution |
(in order) False, False, True |
| Marking Scheme | 2 marks for each correct answer (no part marks) |
| Common Errors and Comments | Mostly well done; the last question was missed
more often than the other two. |
Part (c) [3 marks]
| Solution |
Data and operations. |
| Marking Scheme |
A. 1 for "data" |
| Common Errors and Comments |
If you said "data type", that would make the definition circular! If you mentioned anything that implied implementation details (e.g. instance variables or methods), you did not get full marks. Remember: An abstract data type does not need a corresponding (concrete) Java class or interface. |
Part (d) [4 marks]
| Solution |
|
| Marking Scheme |
A. 2 for |
| Common Errors and Comments |
Generally well done. Some students misinterpreted the question to |
Question 2 [20 marks]
Part (a) [5 marks]
| Solution |
|
| Marking Scheme | A. 1 for "items stores the
Strings currently in this list"B. 1 for "in non-decreasing sorted order" C. 1 for "at positions 0 to n-1"D. 1 for " n is the size of the Vector"E. 1 for having nothing else (e.g. method specifications, code) |
| Common Errors and Comments | Not many people got C or D. A few people did not understand entirely what a representation invariant is. Remember that a representation invariant should describe the purpose and state of all of the instance variables when no methods are executing, at any point during the execution of the program. It should not mention anything else. |
Part (b) [15 marks]
| Solution |
|
| Marking Scheme | A. 1 for the precondition B. 1 for the postcondition (described formally or informally) C. 1 for mention the parameter D. -1 for mentioning implementation details E. 1 for using a previous pointer F. 3 for using a current pointer and looping through the list G. 3 for stopping the loop when current.data.compareTo(data) >= 0 H. 1 for creating the new node for 'data' I. 1 for handling the case where the node must be inserted at the beginning J. 2 for handling the case where the node is inserted anywhere else K. 1 for providing good comments, or making the code clear enough that I could understand how it would work |
| Common Errors and Comments |
Many students made lots of small mistakes. A very common error was to address I at the start of the method. Note that you may still have to insert the new node at the beginning even after traversing the list to look for the place to insert the new node. |
Question 3 [20 marks]
Part (a) [10 marks]
| Solution |
|
| Marking Scheme | A. 1 for having 6 numbers, printed two per line B. 4 for having the first line correct C. 2 for having the second line logically follow from the second D. 3 for having the third line logically follow from the first and third |
| Common Errors and Comments | A very common error was to begin with the line
15 30. Of course, this is incorrect because you are supposed
to use the stuff() method inside Jetta and PassatWagon.
Another common error was to write Note that part-marks were assigned. I tried to mark your answers so that even if you were wrong on the first answer, you could still get part-marks if the second and third lines logically followed from the first. A few students told me after the midterm that they spent a lot of time on this question. Many of those students spent time drawing out the entire memory model. This question did not ask you to draw the memory model; it just asked you to trace the program. So, if you can trace the program without drawing out the memory model, then avoid the extra work! Only bring in the memory model when you get into trouble. |
Part (b) [10 marks]
| Solution |
|
| Marking Scheme |
A. -1 for extra frames |
| Common Errors and Comments |
Most students made many small mistakes. A few students told me after the midterm that they did not have time for this question. Many of those students did this question last. I am sure that if they had done this question first, they would have picked up many of the 10 marks, because this question was meant to be easy. All you had to do was look at the last four statements and you would see that the same object address was used for all the references involved (half the marks for this question!). Moral of the story: Read through the entire midterm first, and then start with the questions with which you are comfortable. |
Last updated on 2000-07-29 by Ray Ortigas.