CS 2401, Fall 2009

Typical mistakes for Test 1

Problem 1/2:

* no recursion

* a piece of code, not a method

* vague explanations instead of an algorithm

* to trace a method, you must call it; some students never call; if you do not 
call the computer does not do anything, there is nothing to trace

Problem 3/4:

* wrong methods which do not produce the desired pattern of symbols

* extra parameters in the method; the only parameter should be n

* a method that only works for 3 rows, not in the general case

Problem 5:

* a sequence of moves is hacked, does not come from the general algorithm

Problem 6:

* wrong algorithm

* methods that print not compute the result

* wrong tracing: some variables are not described at all, a single method is
depicted by several boxes, etc.

* to trace a method, you must call it

* a code but no method, and Problem 6 asks for a method

* a method that works only on the example, but not in the general case (e.g.,
only for city 1)

Problem 7:

* wrong for-loop, should be a vector-oriented for-loop

* wrong algorithm: e.g., forgetting to initialize the sum variable to 0 (it then 
starts with a garbage value, not with zero) or computing the average instead of 
the sum

* a code which is not a method

Problem 8:

* running time for recursion is actually larger than for the for-loop; we had
an example with Fibonacci numbers in class

* some parts of the question are sometimes not answered at all, e.g., about the 
running time