```
CS 2401, Spring 2009

Typical mistakes for Test 1

Problem 1/2:

* explanations are either wrong (i.e., contain wrong formulas), or are missing
altogether;

* 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

* if a method sumSquares(n) returns an integer, you cannot call it in the main
method by simply writing sumSquares(3); you need to assign this value to some
variable or print it

* n^2 is not a legal way to describe square in Java; you need n * n or use
exponential function

Problem 3/4:

* some students simply copied their method for checking palindromes that they
designed for the lab; the task is different here;

I do not think that an excuse of "I did not understand the problem" is a good

* some methods do not use any recursion and simply return "true" when the first
and the last characters match; this is not right, because we can have no matching
inside: e.g., in ACAT, the endpoints A and T match, but the inside letters
C and A do not

* a symbol A has to be written in quotes; == A means comparing with a variable A,
you need == 'A' to compare with the letter A

* logic is sometimes wrong for detecting matching

* some students wrote an auxiliary method, but the main method for checking
whether a given sequence is palindrome-type is missing

* equals is a method applicable only to strings, not to characters

Problem 6:

* some students computed the average of all the temperatures measured at all the
stations, not the average at this particular station; tracing should have caught
this mistake since the average of all 4 values is 67.5

* 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 station 1)

* local variables, i.e., variables defined within a method, should be listed
within the corresponding method box, since after the method finished working, all
these variables disappear

Problem 7:

* in the Vector, parameter cannot be int should be Integer, since we need a
reference type

* every variable must have a number, you cannot use the type Vector as a name

* some methods are not general, they only work on the example,
when the vector has 2 components, but not in the general case

* forgot to initialize the variable that contains the sum; it then starts with a
garbage value, not with zero

* 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

Problem 9:

* you cannot just write the name of the variable, you need to assign it to
something or print it or something

* you need to define a variable of the enumerated type

* enumerated type is not a vector, it is a completely different construction

Problem 10:

* need to initialize the value largestSoFar

* sometimes, an auxiliary method is there, but the main method is missing
```