Midterm 2 Postmortem

Math 10 -- D. C. Smolarski, S.J.
Santa Clara University, Department of Mathematics and Computer Science

[Return to Math 10 Homepage]

NOTES:

Prob 1:

Bubblesort (not selection sort) works by swapping adjacent elements.

Prob 2:

Some people had difficulty realizing that both for loops with cout statements printed out 5 elements. The values of the elements in the second output line were computed from the recently revised elements, not from the original elements!

Prob 3:

Some people ignored the 2 in front of f(n-1) and others ignored the -2 as the last term in the recursion formula.

Prob 4:

Some people interpreted the array a[] as a class rather than an integer array. A number of people had problems trying to decide how to determine whether something was negative.

Prob 5:

The first component of the class should be a character array of length 41 (not merely 40) in order to allow for 40 characters and a null character. The other components are not arrays.

Also, the name of the class is person as the instructions give.

Finally, the class must have a public attribute for every component or else certain sections cannot be accessed.

Prob 6:

Inside the function, one has to use the full variable name, i.e., person.units since this is not a member function and the class variable person is a parameter.

A number of people did not interpret "initial charge of $8000 plus $400 for each unit over 20" correctly.

Some people used "$" or commas within the code.

There was also some problems in terms of the inequalities to test for the 3 different cases. If you test for something > 20 and then test for the same thing > 12, the second condition will also be true whenever the first is true! One must make careful use of "else" statements and inequalities so that you don't have a situation where two conditions can both be fulfilled, with the second one (incorrectly) resetting what the first condition did!

Prob 7:

MANY people ignored the second question in each part -- i.e., what is the name given to a constructor/destructor.

Prob 8:

There seemed to be some confusion between the subscript and the (possible) value contain in the array element. Some people attempted to sum the values in the arrays and/or print out the values, rather than the subscripts.

Also, when the return statement is executed, either in the main program or in a function, the code ends and returns to the calling program (or the program merely stops). The return does not force the loop to end early and the program to continue after the loop with the other cout statement.

Finally, the last cout statement is OUTSIDE the loop, and in this case, is never executed.

Prob 8:

There should be a total of five values printed out.

Statistics

Distribution

                  x
               x  x
               x  x
               x  x
               x  x
            x  x  x  x
         x  x  x  x  x
         x  x  x  x  x
         x  x  x  x  x
      x  x  x  x  x  x
     40 50 60 70 80 90
     (1  4  5  9 10  5)

Number of Perfect Scores per Problem

  1. 23/34 ("Easiest")
  2. 6
  3. 19
  4. 12
  5. 9
  6. 5 ("Hardest")
  7. 6
  8. 15
  9. 16

This page is maintained by Dennis C. Smolarski, S.J. dsmolarski@math.scu.edu
© Copyright 1999 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 20 February 1999.