CS 2401, Fall 2010

Typical mistakes for Test 1

PROBLEM 1/2, MW version:

* instead of a general code that we asked, the code that only
works on a given example; let us explain why this is wrong:
if we ask for a code for adding two numbers and then ask to trace
it for 2 and 2, then a program that always returns 4 is NOT a
correct answer

* we ask to delete a student with a given number NOT a student
with a given name

* if we delete a student F from a list consisting of 4 elements

0. A
1. B
2. F
3. C

then we should get a list consisting of three elements

0. A
1. B
2. C

NOT a list of 4 elements in which element 2 is an empty string

* vectors not only have advantages, they also have disadvantages
in comparison with arrays -- e.g., they are slower

* syntax of dealing with vectors is often wrong

PROBLEM 1/2, TR version:

* 5/9 in Java is 0; to get a non-zero value, one must use real
numbers not integers, e.g., 5.0/9.0

* not using the array at all

* returning one number instead of a list

* using an array-type loop instead of a simpler vector loop

* printing elements instead of computing them; there was no
requirement to print

* writing a code that only works on a given example (see
a similar problem with Question 1/2 in MW version)


* forgetting to return a value in a method of type

* writing a piece of code and not a method

* computing the original Fibonacci sequence instead of a new one


* writing a piece of code and not a method

* a method that only works on the example and not in the general

* a new array computed but not returned

* tracing means describing step by step how the values of ALL
the variables change, NOT just the few variables you select


* algorithm is, by definition, a precise description of steps;
vague description using a word "recurse" is NOT an algorithm

* algorithm should match the code, otherwise if there is an
algorithm and then a code that has nothing to do with it, what
is the purpose of this algorithm?

* tracing means describing how the value of each variable change,
not just a few of them

* the task was to use recursion, some methods do not call
themselves at all

* printing a wrong pattern


* no examples, the task was also to give examples