Prob 1: Some people were confused because of the missing nodes.
Prob 4: The "selection sort" statement is false. The swapping of adjacent elements is the method used in bubblesort.
Prob 7: Templates deal with an interdeterminate variable datatype when defining a class or a function. The datatype is determined when the class or function is actually used. (Notes N23)
Inheritance -- see Notes N14 -- deals with one class "inheriting" everything from another class.
const variable parameter modifiers -- see Notes M1.
Prob 8: See Notes 8, "Warnings," #1.
Prob 10: A great number of people obtained the answer of 20 for m in the first code. This ignored the fact that both i and j are bound to n in the main program so that when i changes, so does j automatically.
Prob 11: Some people failed to use a real number in division or multiplication, which would have rendered a final answer without any "cents" portion (i.e., since all variables are of type int, division by an integer number would truncate any decimal portion).
Prob 12: A number of people had something such as temp=n*n which only computes n2 repeatedly, since the value of n was not changed. Also some people fell into the trap of including a cout statement inside both routines -- there is no reason the PRINT OUT the value which should be returned.
In the recursive code, some people included a loop which, as a rule, is NEVER included in recursive code. Also, since recpower is a value function, the return value must be stored in some variable.
Prob 13: This was basically the same problem as on Midterm II. The last cout is NOT done because the return statement in the middle of the loop either pops out of the function (if this were a function) or quits the main program (if this were a main program).
Prob 14: A several of people reversed the first assignment for some unknown reason.
Prob 16: A number of people went into the recursion, but did not "pop" out if it. In other words, there were correct answers from the first cout statement, but the second cout was ignored.
Some people included a 0 as part of the output, I guess, by assuming that the return statement printed out a 0 (which it doesn't).
final nfinal
194 77
191 75
186 72
186 72
182 69
179 67
178 66
170 61
168 59
167 58
167 58
163 56
163 56
161 54
160 54
158 52
156 51
152 48
149 46
142 41
141 40
140 40
135 36
133 35
132 34
124 29
124 29
124 29
123 28
97 10
MAXIMUM 200 100
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
80- 100- 120- 140- 160- 180-
99 119 139 159 179 200
This page is maintained by Dennis C. Smolarski, S.J.
dsmolarski@math.scu.edu
© Copyright 2000 Dennis C. Smolarski, SJ, All rights reserved.
Last changed: 7 December 2000.