Programs with incorrect or no output received a grade between 20 and 40.
Items in boldface were common.
Items are listed in the order that they were seen as I graded the assignments.
DEDUCTION |
PROBLEM |
COMMENT |
-2 |
if( cond ) return true; else return false; |
Should be: return cond; |
-15 |
Consistently not checking for emptiness in find and delete operations |
|
-3 |
One-time not checking for emptiness in find and delete operations |
|
-7 |
Catching the
exception in find and delete operations |
Should let it propagate
back to caller. |
-10 |
Consistently creating extra arrays, especially in deleteMax |
|
-3 |
One-time creation of unneeded extra array |
|
-2 |
Underflow constructor not made public |
|
-10 |
Insufficient Javadoc comments |
|
-6 |
Javadoc comments attempted, but in wrong place |
Prior to the method, rather than in the method |
-10 |
Complicated logic |
Each method should fit easily in 60 lines. |
-3 |
Consistently inconsistent spacing. For instance, one
loop looks like a[i
] = a[ i+1 ]; Another looks like a[ i]= a[ i + 1 ]; |
Pick one style and stick with it. |
-10 |
Indenting disaster |
|
-5 |
Indenting problem |
|
-3 |
One time indenting problem that was really misleading to the reader |
|
-7 |
Horrible variable names |
|
-3 |
Using o or l as a variable name |
Avoid because they look like 0 and 1. |
-2 |
Missing else, as in if( x < 0 ) { … } if( x >= 0 ) { … } |
Rewrite as if/else. |
-5 |
makeEmpty doubling inconsistency |
If you (exactly) doubled the array, then you could not have makeEmpty resize the array to length 0, without creating a bug. |
-3 |
Putting an isEmpty test too late (i.e. after indexing the array). |
The test had to be the first line of code. |
-15 |
Messing up the default comparator completely. |
|
-5 |
Having the default comparator return 0 if one type is not Comparable. |
Should let the ClassCastException that is generated go through. |
-5 |
UnderflowException
extends the wrong class. |
Must extend RuntimeException. |
-3 |
Gratuitious calls to create objects, as in Object temp = new Object(); |
Should have been Object temp = null; |
-2 |
Nonsense code; for instance random calls that ignore return values. |
|
-15 |
Nested loops in the
insert
routine, or doing a full sort. |
You should not have
needed to nest loops. Generally lost points unless there was a comment or an
early break from the outer loop. |
-5 |
Declaring extra instance variables instead of local variables. |
|
-5 |
Print statement in the exception constructor. |
Contructor shouldn’t do anything, except call super. |
-2 |
Using a while loop instead of an obvious for loop. |
|
-5 |
Constructing an exception object but not throwing it. |
|
-5 |
Having toString print the size, but not the items. |
|
-5 |
makeEmpty throws an exception if already empty. |
This is an unreasonable design decision. There is nothing usual about clearing a container that is already cleared. It is similar to initializing to 0 a variable that is already 0. |
-8 |
One parameter constructor that accepts a Comparator messed up. |
|
-2 |
Writing an else if, when an else was enough as in: if( x < 0 ) { … } else if( x >= 0 ) { … } |
Rewrite as if/else. |
-11 |
Test for emptiness, but no attempt to create or throw the exception. |
|
-3 |
Using System.arrayCopy when not needed, which often involved creation of a temporary array. |
|
-0 |
Using size==0
instead of calling isEmpty. |
|
-5 |
Abusive use of ++ operator, as in a[i]
= a[++i]; |
|
-1 |
Keeping capacity as a separate member |
Already stored as array length. |
-3 |
No space in toString to separate the items output, resulting in one giant string with no blanks. |
|
-1 |
Placing throws RuntimeException in the signature of a method. This is meaningless. |
|
-5 |
Having isEmpty work by testing items[0]==null might not work, depending on implementation of deleteMin and deleteMax. If it didn’t work, points were deducted. |
|
-5 |
Catching ArrayIndexOutOfBoundsException to decide when it is time to expand the array. |
This is a big no-no. The test should be done explicitly, and exceptions should not be used as a substitute for if/else. |
-15 |
findMin/deleteMin didn’t simply look in position 0, but searched the entire array. |
|
F for course |
Cheating. |
|